I have been trying to solve an issue with combined reports coverage for some time now, and I can't seem to find any useful information that's relevant to my particular issue.
Implementation Details:
- SonarQube (v5.4)
- jacoco-maven-plugin (v0.7.9)
- sonar-jacoco-listener (v2.8)
- SonarQube Scanner for Jenkins (v2.8)
- maven-surefire-plugin (v2.16)
- maven-failsafe-plugin (v2.18.1)
- junit (v4.12)
I have jacoco-maven-plugin configured and properly generating both unit and integration test reports, including coverage by test via the sonar-jacoco-listener module.
However, when the SonarQube Scanner for Jenkins (v2.8) performs its analysis, a sensor called JacocoOverallSensor checks a third file, jacoco-overall.exec, which does NOT have coverage by test information in it.
As a result, I do not actually get any Coverage by Test information rendered in the SonarQube Coverage tab for my project at all, only lines and conditions per class.
Example output from Scanner:
INFO: Sensor SurefireSensor
INFO: parsing /var/lib/jenkins/workspace/evo-sonar-test/target/junit-reports
INFO: Sensor SurefireSensor (done) | time=160ms
INFO: Sensor JaCoCoSensor
INFO: Analysing /var/lib/jenkins/workspace/evo-sonar-test/target/jacoco/jacoco-unit.exec
INFO: Information about coverage per test has been collected.
INFO: Sensor JaCoCoSensor (done) | time=887ms
INFO: Sensor JaCoCoItSensor
INFO: Analysing /var/lib/jenkins/workspace/evo-sonar-test/target/jacoco/jacoco-itest.exec
INFO: Information about coverage per test has been collected.
INFO: Sensor JaCoCoItSensor (done) | time=365ms
INFO: Sensor JaCoCoOverallSensor
INFO: Analysing /var/lib/jenkins/workspace/evo-sonar-test/target/jacoco/jacoco-unit.exec
INFO: Analysing /var/lib/jenkins/workspace/evo-sonar-test/target/jacoco/jacoco-itest.exec
INFO: Analysing /var/lib/jenkins/workspace/evo-sonar-test/.sonar/jacoco-overall.exec
INFO: No information about coverage per test.
INFO: Sensor JaCoCoOverallSensor (done) | time=333ms
Based on my understanding from looking at the package/classes for JacocoOverallSensor, this jacoco-overall.exec is supposed to be a merged copy of the integration and unit jacoco reports generated. The jacoco-overall.exec file is getting created and is populated with data, meaning a merge of my unit/integration tests is happening, but it appears that only the Coverage by Test information is missing from this file.
At this point, I'm stumped as to why this is. I've searched and searched, but I can't seem to find anyone who ONLY has an issue with coverage by test in jacoco-overall.exec and not in the unit/integration exec files as well.
Questions:
- Is there some configuration value I'm missing that allows unit/integration Coverage By Test information to be merged in the jacoco-overall.exec?
- Is a merge of the two reports even necessary (and can I somehow turn merging off in the Sonar Scanner)? All I ultimately need out of my setup is to be able to view coverage by test for unit and integration tests respectively - overall combined coverage isn't needed at this time.
For reference, my sonar configuration (configured in Sonarqube Scanner for Jenkins):
# Data locations to be analyzed
sonar.sources=src/main
sonar.tests=src/test
sonar.java.binaries=target/classes
sonar.java.libraries=target/libs
sonar.java.test.binaries=target/test-classes
sonar.java.test.libraries=target/libs
sonar.junit.reportsPath=target/junit-reports
# Compiler configuration
sonar.java.source=1.7
sonar.language=java
sonar.sourceEncoding=UTF-8
# Jacoco configuration
sonar.java.coveragePlugin=jacoco
sonar.jacoco.reportMissing.force.zero=true
sonar.jacoco.reportPath=target/jacoco/jacoco-unit.exec
sonar.jacoco.itReportPath=target/jacoco/jacoco-itest.exec
I'd be happy to post more information on request, but at this point I'm so lost/cross-eyed in the sea of information about this topic that I'm not sure what else would be helpful for people. Ask and you shall receive.