I'm using SonarQube 4.5.4, and the SonarQube Runner version is 2.4.
I have defined the sonar.jacoco.reportPath=jacoco/jacoco-ut.exec
(the result of junit4 ant task which integrated the jacoco as coverage tool) in the sonar-project.properties
file.
The exec file looks fine, it's contains all the coverage information per test, I've imported it with the EclEmma 2.3.2.201409141915 and all the coverage information is there.
In the SonarQube dashboard it's reflecting in strange way:
The cevarage is taken as Overall / IT coverage, instead of UT coverage. and the UT coverage is missing, BTW also the duplication is set to 0% (and it's not true) from Sonar log it's looks like this:
08:24:34.604 INFO - Sensor SurefireSensor done: 713 ms
08:24:34.604 INFO - Sensor JaCoCoOverallSensor...
08:24:35.140 INFO - Analysing /ibmshome/cc/cctlg/sonar/sonar/ens-14023/./.sonar/ATT_MO_API_TlgServer_ATT_TlgServer_module/jacoco-overall.exec
08:24:52.505 INFO - No information about coverage per test.
08:24:52.505 INFO - Sensor JaCoCoOverallSensor done: 17901 ms
08:24:52.505 INFO - Sensor CoberturaSensor...
08:24:52.506 WARN - Cobertura report not found at /ibmshome/ibms/ibms/target/site/cobertura/coverage.xml
08:24:52.506 INFO - Sensor CoberturaSensor done: 1 ms
08:24:52.506 INFO - Sensor JaCoCoSensor...
08:24:52.815 INFO - Analysing /ibmshome/ibms/ibms/ccirp/proj/sbmsIrd1000/jacoco/jacoco-ut.exec
08:25:04.966 INFO - No information about coverage per test.
08:25:04.966 INFO - Sensor JaCoCoSensor done: 12460 ms
I'm looking for solution for a long time, also tried to change properties and adding sonar.jacoco.itReportPath
as dummy, and also getting the same result.
You are seeing overall coverage in SonarQube because you may have the widget for Integration test enabled/set. It's not possible that you are seeing 0% in UT or IT tests but Overall is showing some valid % other than 0.
As per the snapshot you pasted, it seems like you are NOT setting sonar.tests=src/test/java or sonar.java.tests=some/test/java i.e. some valid folder value where all your test source code reside.
For getting the coverage, make sure you set either sonar.jacoco.reportPath=full/relative/path/to/the/jacoco-ut-file.exec and also set the sonar.sources, sonar.tests, sonar.jacoco.itReportPath=full/relative/path/to/jacoco-nonUT-actually-IT.exec file
NOTE: With the newer versions of SonarQube, most of the properties now have java/language name embedded in the properties i.e. sonar.binaries may now be sonar.java.binaries or sonar.groovy.binaries
See setting sonar.java.sources, sonar.java.tests, sonar.java.binaries, sonar.jacoco.reportPath but these will work as it's sonar.jacoco.itReportPath to the correct values helps!
Also, try these settings on a new project if for some reason your project in SonarQube is corrupt and now showing valid data after each evaluation.