我们有一个构建链,它创建一个Eclipse RCP应用程序和一系列存储库。我们希望在构建链完成时运行集成测试。因此,在完成RCP应用程序构建之后,我们添加了两个Jenkins作业。第一个作业部署RCP应用程序并从存储库安装特性。第二个作业针对部署的应用程序执行RCPTT测试脚本。我们希望从这些测试中捕获代码覆盖率,并在Sonarqube中显示它们。我修改了我们的RCPTT运行器执行以添加jacoco代理,该代理运行并生成Jacoco-it.exec数据文件。如果我在Eclipse中加载这个数据文件到EclEmma,我就可以查看覆盖率信息。我还没有弄清楚如何将这些数据加载到Sonarqube中。
jacoco代理收集的原始数据是否可以直接加载到SonarQube中(或者在加载之前必须经过另一个过程步骤)?
jacoco代理收集的原始数据是否足以在SonarQube中获得覆盖信息,或者应用程序的类文件是否需要在加载时出现?
我们当前运行RCPTT测试的结构是一个多模块结构。有一个父pom,它将执行按特性组织的RCPTT执行。每个RCPTT执行都有一个模块。目前,我只是测试与一个模块和一些脚本。我正在通过从命令行运行maven进行测试。
母体Pom
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.compuware.mf.topaz.product</groupId>
<artifactId>parent</artifactId>
<version>17.2.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>MFM Components : Topaz RCPTT</name>
<parent>
<groupId>com.compuware.mf</groupId>
<artifactId>parent</artifactId>
<version>0.0.11-SNAPSHOT</version>
</parent>
<!-- RCPTT Maven Plugin and RCPTT Runner are hosted in this repository -->
<pluginRepositories>
<pluginRepository>
<id>org.jacoco</id>
<name>Maven Central repository</name>
<url>http://repo1.maven.org/maven2/</url>
</pluginRepository>
<pluginRepository>
<id>rcptt-releases</id>
<name>RCPTT Maven repository</name>
<url>https://repo.eclipse.org/content/repositories/rcptt-releases/</url>
</pluginRepository>
</pluginRepositories>
<properties>
<!-- RCPTT properties -->
<rcptt-maven-version>2.1.0</rcptt-maven-version>
<rcptt-runner-version>2.2.0-M1d</rcptt-runner-version>
<testFailureIgnore>true</testFailureIgnore>
<!-- Sonar properties -->
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<!-- sonar.jacoco.reportPath>${project.basedir}\..\rcptt-coverage/jacoco-it.exec</sonar.jacoco.reportPath -->
<sonar.jacoco.itReportPath>${project.basedir}\..\rcptt-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>process-resources</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${project.basedir}/../rcptt-coverage/jacoco-it.exec</destFile>
<propertyName>failsafeArgline</propertyName>
</configuration>
</execution>
<!--
Ensures that the code coverage report for integration tests after
integration tests have been run.
<execution>
<id>post-integration-test</id>
<phase>process-classes</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
< Sets the path to the file which contains the execution data. >
<dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
< Sets the output directory for the code coverage report. >
<outputDirectory>${project.build.directory}/jacoco-it</outputDirectory>
</configuration>
</execution>
-->
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.rcptt</groupId>
<artifactId>rcptt-maven-plugin</artifactId>
<version>${rcptt-maven-version}</version>
<extensions>true</extensions>
<configuration>
<!-- This element describes where to get an AUT to run tests -->
<aut>
<!-- Use AUT from previous build step. By specifying path -->
<explicit>${project.basedir}/../com.compuware.mf.topaz.rcptt.topaz-install-byant/aut/</explicit>
<injections>
<!-- features are optional - when omitted, all features from given site will be installed -->
<injection>
<site>${test-repository}</site>
<features>
<feature>${test-feature}</feature>
</features>
</injection>
</injections>
<vmArgs>
<vmArg>${failsafeArgline}</vmArg>
</vmArgs>
</aut>
<runner>
<version>${rcptt-runner-version}</version>
<vmArgs>
<vmArg>-Xmx2048m</vmArg>
</vmArgs>
</runner>
<testOptions>
<!--How many seconds Runner should wait for application startup.-->
<autStartupTimeout>600</autStartupTimeout>
<!-- Timeout for all tests, in seconds (90 minutes)-->
<execTimeout>5400</execTimeout>
<!-- Timeout for a single test case, in seconds -->
<testExecTimeout>900</testExecTimeout>
<!-- application-under-test connection timeout in seconds -->
<!-- setting this up in case the install being long running -->
<connectTimeout>600</connectTimeout>
<!-- contextWaitforjobsTimeout>120000</contextWaitforjobsTimeout> -->
<jobHangTimeout>300000</jobHangTimeout>
<!-- print memory usage -->
<memoryUsage/>
<!-- When set to true, in case of test failure AUT will be restarted. This significantly
slows down execution, but may be useful for some test suites -->
<restartAUTOnFailure>false</restartAUTOnFailure>
</testOptions>
<projects>
<project>${project.basedir}/../rcptt.workbench</project>
<project>${project.basedir}/../rcptt.hostservices</project>
</projects>
<suites>
<suite>SuiteZosConsole</suite>
</suites>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>0.7.7.201606060606</version>
</dependency>
</dependencies>
<modules>
<module>../com.compuware.mf.topaz.rcptt.hostservices-test</module>
</modules>
模块Pom
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>com.compuware.mf.topaz.rcptt.hostservices-test</artifactId>
<groupId>com.compuware.mf.topaz.product</groupId>
<version>17.2.3-SNAPSHOT</version>
<parent>
<groupId>com.compuware.mf.topaz.product</groupId>
<artifactId>parent</artifactId>
<version>17.2.3-SNAPSHOT</version>
<relativePath>../com.compuware.mf.topaz.rcptt.test.parent</relativePath>
</parent>
<properties>
<test-repository>http://dtw-svngateway.prodti.compuware.com/CommonBundleDepot/products/Enterprise/hostservices/${buildType}</test-repository>
<test-feature>com.compuware.frameworks.hostservices.rcptt.test.feature.feature.group</test-feature>
</properties>
<!-- RCPTT Maven Plugin provides this packaging type -->
<build>
<plugins>
<plugin>
<groupId>org.eclipse.rcptt</groupId>
<artifactId>rcptt-maven-plugin</artifactId>
<version>${rcptt-maven-version}</version>
</plugin>
</plugins>
</build>
<packaging>rcpttTest</packaging>
下面的第一个命令执行RCPTT。第二个命令执行声纳目标。
MVN--fail-at-end-dbuildtype=trunk-nightly-repo clean verify
MVN-E-B声纳:sonar-dsonar.host.url=http://localhost:9000
RCPTT日志
[INFO] Scanning for projects...
[INFO] Building MFM Components : Topaz RCPTT 17.2.3-SNAPSHOT
[INFO] ...
[INFO] --- jacoco-maven-plugin:0.7.7.201606060606:prepare-agent (pre-integration-test) @ parent ---
[INFO] failsafeArgline set to -javaagent:C:\\Users\\dresser\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.7.7.201606060606\\org.jacoco.agent-0.7.7.201606060606-runtime.jar=destfile=C:\\p\\e46\\topaz\\trunk-all\\com.compuware.mf.topaz.rcptt.test.parent\\..\\com.compuware.mf.topaz.rcptt.test.parent\\target\\jacoco-it.exec
[INFO]
[INFO] --- rcptt-maven-plugin:2.1.0:execute (default-execute) @ com.compuware.mf.topaz.rcptt.hostservices-test ---
[INFO] Runner command line is cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_91\jre\bin\java.exe" -Xmx2048m -jar C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\runner\eclipse\plugins\org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar -application org.eclipse.rcptt.runner.headless -data C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\runner-workspace -aut C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\..\com.compuware.mf.topaz.rcptt.topaz-install-byant\aut\eclipse -autWsPrefix C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\aut-ws- -autConsolePrefix C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\results\aut-console- -autVMArgs -javaagent:C:\\Users\\dresser\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.7.7.201606060606\\org.jacoco.agent-0.7.7.201606060606-runtime.jar=destfile=C:\\p\\e46\\topaz\\trunk-all\\com.compuware.mf.topaz.rcptt.hostservices-test\\..\\com.compuware.mf.topaz.rcptt.test.parent\\target\\jacoco-it.exec -q7report C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\results\com.compuware.mf.topaz.rcptt.hostservices-test.report -htmlReport C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\results\com.compuware.mf.topaz.rcptt.hostservices-test.html -junitReport C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\surefire-reports\TEST-com.compuware.mf.topaz.rcptt.hostservices-test.xml -import C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\projects\com.compuware.mf.topaz.rcptt.hostservices-test;C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test/../rcptt.workbench;C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test/../rcptt.hostservices -injection:site http://dtw-svngateway.prodti.compuware.com/CommonBundleDepot/products/Enterprise/hostservices/trunk-nightly-repo;com.compuware.frameworks.hostservices.rcptt.test.feature.feature.group -testOptions autStartupTimeout=600;connectTimeout=600;execTimeout=5400;jobHangTimeout=300000;memoryUsage=null;restartAUTOnFailure=false;testExecTimeout=900 -timeout 5400 -shutdownListenerPort 8347 -suites SuiteZosConsole"
[INFO] The execution timeout is set to 5400 seconds
[INFO] Started at Thu Jan 12 09:13:34 EST 2017
[INFO] RCPTT Runner version: 2.2.0
[INFO] ...
[INFO] Testcase Artifacts:7
[INFO] ...
[INFO] Pass 1 (7) processed. 0 failed. spent: 0:29, 1:27 mins remaining. CommandHistory. time: 28150ms
[INFO] Pass 2 (7) processed. 0 failed. spent: 0:59, 0:59 mins remaining. ConnectToHost. time: 29032ms
[INFO] Pass 3 (7) processed. 0 failed. spent: 1:19, 0:47 mins remaining. GetActiveSystemLog. time: 18693ms
[INFO] Pass 4 (7) processed. 0 failed. spent: 1:33, 0:31 mins remaining. IssueZOSConsoleCommand. time: 13788ms
[INFO] Pass 5 (7) processed. 0 failed. spent: 1:45, 0:15 mins remaining. OpenSystemLogs. time: 10854ms
[INFO] Pass 6 (7) processed. 0 failed. spent: 1:57, 0:00 mins remaining. SystemLogOptions. time: 11423ms
[INFO] Pass 7 (7) processed. 0 failed. spent: 2:21, 0:00 mins remaining. ZOSandTSOConsole. time: 20994ms
[INFO] Process terminated. Shut down AUTs
[INFO] Finished at Thu Jan 12 09:17:20 EST 2017
[INFO] Runner exit code is: 0
[INFO] ...
[INFO] BUILD SUCCESS
[INFO]
[INFO] Total time: 04:04 min
[INFO] Finished at: 2017-01-12T09:17:27-05:00
[INFO] Final Memory: 13M/160M
[INFO]
声纳测井
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] MFM Components : Topaz RCPTT
[INFO] com.compuware.mf.topaz.rcptt.hostservices-test
[INFO] Downloading: http://dtw-mfmstbldsvr.nasa.cpwr.corp:8090/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml
[INFO] Downloading: https://repo.eclipse.org/content/repositories/rcptt-releases/org/apache/maven/plugins/maven-metadata.xml
[INFO] Downloading: https://repo.eclipse.org/content/repositories/rcptt-releases/org/sonarsource/scanner/maven/maven-metadata.xml
[INFO] Downloading: http://dtw-mfmstbldsvr.nasa.cpwr.corp:8090/nexus/content/groups/public/org/sonarsource/scanner/maven/maven-metadata.xml
[INFO] Downloaded: http://dtw-mfmstbldsvr.nasa.cpwr.corp:8090/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml (14 KB at 59.0 KB/sec)
[INFO] Downloading: http://dtw-mfmstbldsvr.nasa.cpwr.corp:8090/nexus/content/groups/public/org/codehaus/mojo/maven-metadata.xml
[INFO] Downloaded: http://dtw-mfmstbldsvr.nasa.cpwr.corp:8090/nexus/content/groups/public/org/codehaus/mojo/maven-metadata.xml (22 KB at 259.9 KB/sec)
[INFO] Downloading: https://repo.eclipse.org/content/repositories/rcptt-releases/org/codehaus/mojo/maven-metadata.xml
[INFO] Downloaded: http://dtw-mfmstbldsvr.nasa.cpwr.corp:8090/nexus/content/groups/public/org/sonarsource/scanner/maven/maven-metadata.xml (240 B at 0.5 KB/sec)
[INFO] Downloading: https://repo.eclipse.org/content/repositories/rcptt-releases/org/sonarsource/scanner/maven/sonar-maven-plugin/maven-metadata.xml
[INFO] Downloading: http://dtw-mfmstbldsvr.nasa.cpwr.corp:8090/nexus/content/groups/public/org/sonarsource/scanner/maven/sonar-maven-plugin/maven-metadata.xml
[INFO] Downloaded: http://dtw-mfmstbldsvr.nasa.cpwr.corp:8090/nexus/content/groups/public/org/sonarsource/scanner/maven/sonar-maven-plugin/maven-metadata.xml (557 B at 0.7 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MFM Components : Topaz RCPTT 17.2.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.2:sonar (default-cli) @ parent ---
[INFO] User cache: C:\Users\dresser\.sonar\cache
[INFO] Load global repositories
[INFO] Load global repositories (done) | time=230ms
[INFO] User cache: C:\Users\dresser\.sonar\cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=5ms
[INFO] SonarQube version: 5.6.4
[INFO] Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=175ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=96ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=1049ms
[WARNING] 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[WARNING] 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[INFO] Publish mode
[INFO] ------------- Scan com.compuware.mf.topaz.rcptt.hostservices-test
[INFO] Load server rules
[INFO] Load server rules (done) | time=366ms
[INFO] Base dir: C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test
[INFO] Working dir: C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.hostservices-test\target\sonar
[INFO] Source paths: pom.xml
[INFO] Source encoding: windows-1252, default locale: en_US
[INFO] Index files
[INFO] 0 files indexed
[INFO] Sensor Lines Sensor
[INFO] Sensor Lines Sensor (done) | time=0ms
[INFO] Sensor Sonar-Sonargraph-Plugin [3.5]
[INFO] ----------------------------------------------------------------
[INFO] Sonargraph: Skipping project com.compuware.mf.topaz.rcptt.hostservices-test [com.compuware.mf.topaz.product:com.compuware.mf.topaz.rcptt.hostservices-test], since no Sonargraph rules are activated in current SonarQube quality profile.
[INFO] ----------------------------------------------------------------
[INFO] Sensor Sonar-Sonargraph-Plugin [3.5] (done) | time=3ms
[INFO] Sensor SCM Sensor
[INFO] Sensor SCM Sensor (done) | time=0ms
[INFO] Sensor XmlFileSensor
[INFO] Sensor XmlFileSensor (done) | time=0ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=1ms
[INFO] Sensor Code Colorizer Sensor
[INFO] Sensor Code Colorizer Sensor (done) | time=0ms
[INFO] Sensor CPD Block Indexer
[INFO] Sensor CPD Block Indexer (done) | time=0ms
[INFO] ------------- Scan MFM Components : Topaz RCPTT
[INFO] Base dir: C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.test.parent
[INFO] Working dir: C:\p\e46\topaz\trunk-all\com.compuware.mf.topaz.rcptt.test.parent\target\sonar
[INFO] Source encoding: windows-1252, default locale: en_US
[INFO] Sensor Lines Sensor
[INFO] Sensor Lines Sensor (done) | time=0ms
[INFO] Sensor Sonar-Sonargraph-Plugin [3.5]
[INFO] ----------------------------------------------------------------
[INFO] Sonargraph: Skipping project MFM Components : Topaz RCPTT [com.compuware.mf.topaz.product:parent], since no Sonargraph rules are activated in current SonarQube quality profile.
[INFO] ----------------------------------------------------------------
[INFO] Sensor Sonar-Sonargraph-Plugin [3.5] (done) | time=0ms
[INFO] Sensor SCM Sensor
[INFO] Sensor SCM Sensor (done) | time=0ms
[INFO] Sensor XmlFileSensor
[INFO] Sensor XmlFileSensor (done) | time=0ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=0ms
[INFO] Sensor Code Colorizer Sensor
[INFO] Sensor Code Colorizer Sensor (done) | time=0ms
[INFO] Sensor CPD Block Indexer
[INFO] Sensor CPD Block Indexer (done) | time=0ms
[INFO] Calculating CPD for 0 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 165ms, dir size=15 KB
[INFO] Analysis reports compressed in 17ms, zip size=5 KB
[INFO] Analysis report uploaded in 44ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/com.compuware.mf.topaz.product:parent
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://localhost:9000/api/ce/task?id=AVmTCzfaIYaDC7fI_-4A
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] MFM Components : Topaz RCPTT ....................... SUCCESS [ 38.800 s]
[INFO] com.compuware.mf.topaz.rcptt.hostservices-test ..... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.343 s
[INFO] Finished at: 2017-01-12T09:18:55-05:00
[INFO] Final Memory: 20M/297M
根据对另一篇文章的回答,我们需要在项目构建的上下文中运行回归测试。我们现在进行测试的方式是在源不存在的情况下收集并尝试加载覆盖率数据。
使用jacoco代理并获取测试覆盖率报告有大量答案。大多数答案都是一半,我有点困惑。 以下是我想做的:1。我的Java应用程序正在某个远程服务器上运行。说IP-192.168.17.7 我使用以下命令运行测试:mvn-Denv=stage-Dmaven。测验失败ignore=true-DsuiteFile=src/test/java/Smoke。xml测试 现在我如何通过使用Jacoco代理获得J
这与预期的一样工作,并且能够列出集成测试的覆盖率。 我们有一个SonarQube服务器运行在版本上,有人知道当使用代理时,该版本的SonarQube是否能够显示集成测试覆盖率吗?
SonarQube不再显示我用jacoco分析的项目的测试覆盖率。似乎SonarQube有了更新(我发现新规则的日期是5月19日)。我还假设,从那时起,不再评估使用jacoco maven插件收集的测试覆盖率。我见过类似问题的老问题,但那是4年前的事了:JaCoCo SonarQube不兼容版本1007 我将POM更新到最新的插件版本0.8.4,但无济于事。有什么想法吗?我需要在哪里更改一些东西,
当我的单元测试通过Emma被“覆盖”时,我试图让Sonar IT代码覆盖为我工作。 我的情况: (1)我有大量使用JMockit的单元测试。删除JMockit不是一个选项。我想获得这些测试的单元测试覆盖报告。 (2)我进行了集成测试,简单地用不同的输入场景运行应用程序的核心服务器端部分(这是一个Spring web应用程序)。我想要它的代码覆盖报告。 对于第(1)部分,我选择使用Emma进行单元测
尝试查看声纳上的单元测试代码覆盖率。我正在使用Jacoco代码覆盖率,并且当我在eclipse中执行我的代码时,能够获得我的项目的代码覆盖率。但是,在 Jenkins 中运行时,我收到以下消息和警告,因为没有要运行的测试,没有要编译的源代码 我可以在声纳上报告一些代码覆盖率,但对于单元测试,它会显示。声纳如何显示单元测试的覆盖率?还有,我如何消除警告消息? 附加我的肯定和雅各插件以及杰本金斯控制台
我正在使用arquillian和tomee远程插件进行集成测试。它工作得很好。但我的代码覆盖率不起作用。我使用Jacoco插件来覆盖代码。在我的Java类Java中遇到异常。朗,乐器。IllegalClassFormatException:检测com/demo/EmpService时出错 如何使用Jacoco在远程容器中进行代码覆盖? 注意:我已经在集成阶段将javaagent(argLine)传