Hi,
We have recently upgraded our SonarQube server from 7.7 to 7.9.2 and now we’re using the new property sonar.coverage.jacoco.xmlReportPaths for Jacoco code coverage with following values:
- target/site/jacoco-aggregated/jacoco.xml
- target/site/jacoco-it/jacoco.xml
- target/site/jacoco/jacoco.xml
However in overall Coverage, displayed in SonarQube, it looks like coverage from Unit tests is missing, which caused significant Coverage drop for most of our projects.
We are using Jacoco maven plugin with following configuration:
</plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<!-- surefire goal hook -->
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco.exec</destFile>
<propertyName>surefire.argLine</propertyName>
</configuration>
</execution>
<!-- surefire report -->
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
</configuration>
</execution>
<!-- failsafe goal hook -->
<execution>
<id>pre-integration-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<propertyName>failsafe.argLine</propertyName>
</configuration>
</execution>
<!-- failsafe report -->
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
<!-- merge goal hook -->
<execution>
<id>merge-results</id>
<phase>verify</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${project.build.directory}/aggregate.exec</destFile>
</configuration>
</execution>
<!-- merge report -->
<execution>
<id>post-merge-report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/aggregate.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregated
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Here are valuesfrom the XML reports:
/target/site/jacoco-it/index.html
Total 1,847 of 14,464 87%
/target/site/jacoco-aggregated/index.html
Total 1,041 of 14,464 92%
Screenshot from SonarQube:
Logs proving all files were processed:
[INFO] 06:13:34.697 Sensor JaCoCo XML Report Importer [jacoco]
[DEBUG] 06:13:34.705 Reading report '/builds/future-icon-load-management/load-management/target/site/jacoco/jacoco.xml'
[DEBUG] 06:13:34.764 Reading report '/builds/future-icon-load-management/load-management/target/site/jacoco-it/jacoco.xml'
[DEBUG] 06:13:34.828 Reading report '/builds/future-icon-load-management/load-management/target/site/jacoco-aggregated/jacoco.xml'
[INFO] 06:13:34.878 Sensor JaCoCo XML Report Importer [jacoco] (done) | time=181ms
Could you please help us with this issue?
Thank you