JaCoCo - SonarQube - 没有关于每次测试的覆盖范围的信息

Ste*_*s10 20 jacoco sonarqube

我正在使用JaCoCo进行代码覆盖.使用junit创建单元测试报告并正确导入它们,以便正确显示单元测试信息.该问题是,我得到的错误消息: 大约每测试覆盖无资料.并且代码覆盖率显示单元测试,集成测试和整体覆盖率的值0%.我检查了sonar-project.properties中的所有必需信息,如binary,src,tests等.

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

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

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

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
Run Code Online (Sandbox Code Playgroud)

这是sonar-runner的日志文件:

13:56:05.883 INFO  - Sensor SurefireSensor...
13:56:05.883 INFO  - parsing C:\work\snapshots\steffen_latest\software\java\test\report\junit
13:56:06.149 INFO  - Sensor SurefireSensor done: 266 ms
13:56:06.149 INFO  - Sensor JaCoCoItSensor...
13:56:06.195 INFO  - Analysing C:\work\snapshots\steffen_latest\software\java\target\it-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:\work\snapshots\steffen_latest\software\java\.sonar\jacoco-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:\work\snapshots\steffen_latest\or_base\software\java\target\jacoco.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
Run Code Online (Sandbox Code Playgroud)

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

先感谢您.

dok*_*par 2

您尝试过使用prepare-agent吗?

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
Run Code Online (Sandbox Code Playgroud)

此外,如果您的覆盖率始终显示 0%,您可能需要遵循以下建议

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