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.
I'm using:
- SonarQube 4.5.1
- SonarRunner 2.4
- MySQL
- junit 4.1.1
- jacoco 0.7.2
The jacoco.exec is located in a file /target in the project base directory.
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
This is the logging file from 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
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..
Thank you in advance.
SonarQube itself does not calculate coverage. To include coverage results in your analysis, you must set up a third-party coverage tool and configure SonarQube to import the results produced by that tool. Below, you'll find guidelines and resources, as well as language- and tool-specific analysis parameters.
To get code coverage reports in a Maven project, we first need to set up the JaCoCo Maven plugin for that project. By integrating the JaCoCo plugin, the results of the code coverage analysis can be reviewed as an HTML report. The current version of the JaCoCo-Maven plugin can be downloaded from the MVN Repository.
Have you tried using the prepare-agent
?
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
Also, if your coverage keeps showing 0%, you might need to follow this advice:
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."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With