JaCoCo - SonarQube - 没有关于每次测试覆盖率的信息 [英] JaCoCo - SonarQube - No information about coverage per test

查看:21
本文介绍了JaCoCo - SonarQube - 没有关于每次测试覆盖率的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 JaCoCo 进行代码覆盖.单元测试报告使用 junit 创建并正确导入,以便正确显示单元测试信息.问题 是,我收到错误消息:没有关于每个测试覆盖率的信息.并且代码覆盖率显示单元测试、集成测试和整体覆盖率的值为 0%.我检查了 sonar-project.properties 中的所有必需信息,例如二进制、src、测试等.

I'm using JaCoCo for Code Coverage. The Unit Test reports are created with junit and they are imported correctly, so that the unit test information is shown properly. The problem is, that I get the error message: No information about coverage per test. and the code coverage is shows the value 0% for unit tests, integration tests and overall coverage. I checked all required information in the sonar-project.properties like binary, src, tests etc.

我正在使用:
- SonarQube 4.5.1
- SonarRunner 2.4
- MySQL
-junit 4.1.1
- jacoco 0.7.2

I'm using:
- SonarQube 4.5.1
- SonarRunner 2.4
- MySQL
- junit 4.1.1
- jacoco 0.7.2

jacoco.exec 位于项目基目录的/target 文件中.

The jacoco.exec is located in a file /target in the project base directory.

您可以在下面看到 sonar-project.properties:从我的角度来看,所有必要的路径都已正确设置.(即二进制、src、测试)

Following you can see the sonar-project.properties: From my point of view all necessary paths are set properly. (i.e. binary, src, tests)

Comma-separated paths to directories with sources (required)
sonar.sources=src

compiled code
sonar.java.binaries=class

source code of unit tests 
sonar.tests=test/src

Comma-separated paths to files with third-party libraries (JAR files in the case of Java)
sonar.java.libraries=jar

Language
sonar.language=java

Encoding of the source files
sonar.sourceEncoding=UTF-8

Additional parameters
sonar.my.property=value

Set Project Base
sonar.projectBaseDir=C:/snapshots/steffen_latest/software/java

Tells SonarQube to reuse existing reports for unit tests execution and coverage reports
sonar.dynamicAnalysis=reuseReports

JUnit path
sonar.surefire.reportsPath=test/report/junit

Tells SonarQube where the unit tests execution reports are
sonar.junit.reportsPath=test/report/junit

Tells SonarQube that the code coverage tool by unit tests is JaCoCo
sonar.java.coveragePlugin=jacoco

Import JaCoCo code coverage report.
Tells SonarQube where the unit tests code coverage report is
Unit Tests Coverage
sonar.jacoco.reportPath=target/jacoco.exec

Tells SonarQube where the integration tests code coverage report is
sonar.jacoco.itReportPath=target/it-jacoco.exec

这是来自 sonar-runner 的日志文件:

This is the logging file from sonar-runner:

13:56:05.883 INFO  - Sensor SurefireSensor...
13:56:05.883 INFO  - parsing C:worksnapshotssteffen_latestsoftwarejava	est
eportjunit
13:56:06.149 INFO  - Sensor SurefireSensor done: 266 ms
13:56:06.149 INFO  - Sensor JaCoCoItSensor...
13:56:06.195 INFO  - Analysing C:worksnapshotssteffen_latestsoftwarejava	argetit-jacoco.exec
13:56:06.726 INFO  - **No information about coverage per test**.
13:56:06.726 INFO  - Sensor JaCoCoItSensor done: 577 ms
13:56:06.726 INFO  - Sensor JaCoCoOverallSensor...
13:56:06.851 INFO  - Analysing C:worksnapshotssteffen_latestsoftwarejava.sonarjacoco-overall.exec
13:56:07.178 INFO  - **No information about coverage per test**.
13:56:07.178 INFO  - Sensor JaCoCoOverallSensor done: 452 ms
13:56:07.178 INFO  - Sensor JaCoCoSensor...
13:56:07.209 INFO  - Analysing C:worksnapshotssteffen_latestor_basesoftwarejava	argetjacoco.exec
13:56:07.521 INFO  - **No information about coverage per test**.
13:56:07.521 INFO  - Sensor JaCoCoSensor done: 343 ms
13:56:07.521 INFO  - Sensor CPD Sensor (wrapped)...
13:56:07.521 INFO  - JavaCpdEngine is used for java
13:56:07.521 INFO  - Cross-project analysis disabled
13:56:09.019 INFO  - Sensor CPD Sensor (wrapped) done: 1498 ms
13:56:09.144 INFO  - Execute decorators...
13:56:16.166 INFO  - Store results in database

谁能给我一个建议可能是什么问题?因为不知道是什么问题...几天以来我一直在研究这个问题,我真的不知道该怎么办..

Could anyone give me an advice what could be the problem? Since I don't know what is the problem... I'm working on this issues since a few days and I really don't know what to do..

提前谢谢你.

推荐答案

你试过使用prepare-agent吗?

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install

另外,如果您的覆盖率一直显示为 0%,您可能需要遵循 这个建议:

Also, if your coverage keeps showing 0%, you might need to follow this advice:

如果您的项目已经使用 argLine 来配置 surefire-maven-plugin,请确保将 argLine 定义为属性,而不是作为插件配置的一部分."

If your project already uses the argLine to configure the surefire-maven-plugin, be sure that argLine defined as a property, rather than as part of the plugin configuration."

这篇关于JaCoCo - SonarQube - 没有关于每次测试覆盖率的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆