SonarQube 6.7 (build 33306) Enterprise Edition
Gradle plugin 2.7
SonarJava 4.15.0.12310
Steps to reproduce:
- Create a gradle project that contains some unit tests and has the “jacoco” plugin applied to generate coverage data
- Specify “sonar.jacoco.reportPaths” property to point to a different location than the unit test output
- Run SonarQube analysis
Expected:
SonarQube should use the data from the files specified in the property
Observed:
SonarQube always uses the output from the gradle test task (build/jacoco/test.exec by default) if it exists, ignoring the property (more accurately, it always uses the first execution data file in its search list, and that is always the unit test output)
Background
I’m using the jacocoMerge task from the jacoco Gradle plugin to merge unit and integration test coverage data as well as coverage from several sub-modules (so that if a class is in one sub-project but tested in another it still counts), but the only way to get SonarQube to use the merged data is to delete the unit test coverage data before running analysis. This is cumbersome and problematic, as re-running analysis will do the merge without the unit test data.