尝试查看声纳上的单元测试代码覆盖率。我正在使用Jacoco代码覆盖率,并且当我在eclipse中执行我的代码时,能够获得我的项目的代码覆盖率。但是,在 Jenkins 中运行时,我收到以下消息和警告,因为没有要运行的测试,没有要编译的源代码
我可以在声纳上报告一些代码覆盖率,但对于单元测试,它会显示。声纳如何显示单元测试的覆盖率?还有,我如何消除警告消息?
附加我的肯定和雅各插件以及杰本金斯控制台日志
好心帮忙
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.4.201312101107</version>
<executions>
<execution>
<id>prepare-unit-test-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>generate-unit-test-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.12.4</version>
</dependency>
</dependencies>
<configuration>
<systemPropertyVariables>
<environment>${env.USER}</environment>
</systemPropertyVariables>
</configuration>
</plugin>
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project Test 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ project test ---
[INFO] Deleting /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:prepare-agent (prepare-unit-test-agent) @ project test ---
[INFO] argLine set to -javaagent:/Users/ray1/.m2/repository/org/jacoco/org.jacoco.agent/0.6.4.201312101107/org.jacoco.agent-0.6.4.201312101107-runtime.jar=destfile=/Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target/jacoco.exec
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ project test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ project test---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ project test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ project test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ project test ---
[INFO] No tests to run.
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (run-unit-tests) @ project test ---
[INFO] No tests to run.
[INFO] Skipping execution of surefire because it has already been run for this configuration
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ project test ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target/project test-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:report (generate-unit-test-report) @ project test ---
[INFO] Skipping JaCoCo execution due to missing execution data file
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ project test ---
[INFO] Installing /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target/project test-0.0.1-SNAPSHOT.jar to /Users/ray1/.m2/repository/com/company/taf/project test/0.0.1-SNAPSHOT/project test-0.0.1-SNAPSHOT.jar
[INFO] Installing /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/pom.xml to /Users/ray1/.m2/repository/com/company/taf/project test/0.0.1-SNAPSHOT/project test-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.801 s
[INFO] Finished at: 2015-04-14T10:25:50-07:00
[INFO] Final Memory: 15M/81M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/pom.xml to com.company.inner/project test /0.0.1-SNAPSHOT/project test-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /Users/ray1/.jenkins/jobs/try10-aprl13/workspace/target/project test-0.0.1-SNAPSHOT.jar to com.company.inner/project test /0.0.1-SNAPSHOT/project test-0.0.1-SNAPSHOT.jar
channel stopped
Finished: SUCCESS
我也有类似的问题,0.0%的覆盖率
经过一番努力寻找正确的解决方案后,我的父pom的配置问题得到了解决,如下所示:
<properties>
<!--Sonar -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.language>java</sonar.language>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
我试过其他几种选择,比如雅可布骨料
您需要将这个部分添加到您的父pom.xml中
<properties>
<!-- Properties to make sure we capture *all* coverage -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.language>java</sonar.language>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
我将SonarQube集成到我们的构建系统中--我在构建代理上安装了sonar-runner-2.4,并为每个解决方案添加了sonar-runner.properties(在TFS上的解决方案文件夹中)。在运行构建时,我在构建代理上编译解决方案后执行sonar-runner。除了单元测试之外,一切似乎都可以工作: 在构建的日志中,我看到近200个测试运行并成功完成,在声纳运行器日志中,我看到以下内
我可以在声纳获得单位测试覆盖率通过使用Jacoco工具的代码覆盖率,并使用其报告在声纳属性文件为'sonar.jacoco.report路径=.../Reports/report.exec'。如何通过使用RAD的默认插件获得SONAR中的单元测试覆盖率,该插件以. coveragedata、. Analysis和. html格式生成报告?
首先:这与SonarQube不显示单元测试成功无关。关于这个话题有很多问题和答案,但它们都没有帮助。 我的设置:在上使用由触发的和默认的surefire测试。这就是Sonarqube的结果: 如您所见,它正确地显示所有项目的单元测试成功。选择一个项目使我们获得了包测试的成功。在这一点上变得奇怪了。例如GUI包:它说8,3%的项目测试成功,但0,0%的包测试成功。这怎么可能? 问题是:为什么xxx.
我尝试在我的应用程序模块中的代码的AndroidKotlin应用程序的声纳Qube中显示测试覆盖范围。我可以生成雅各的覆盖结果并显示声纳Qube分度仪,但问题是测试覆盖范围未显示在声纳Qube中: https://imgur.com/a/xOjxLl1 在我的项目的build.gradle中,我有: 在我的身体里。我的应用程序模块的gradle 我生成我的Jacoco报告: 并使用:生成我的son
问题内容: 从不同的代码库执行业务测试时,我必须获得应用程序的代码覆盖率。 我使用:Maven作为我的构建Jbehave作为我的测试框架。测试是用Java编写的。 我的应用程序是部署在tomcat上的一组war文件。 应用程序代码库与测试代码库是分开的。 为了获得覆盖范围,我遵循以下步骤。 1使用maven编译测试代码。 2将应用程序类从其构建位置($ {app.code.dir} / targe
正如我在开始时所说的,单元测试成功率确实成功地显示出来,所以我相信只需要一个小的改变就可以使单元测试复盖范围发挥作用。 任何帮助都将不胜感激!