SONAR code coverage including both UT and IT tests

We have a multimodule project which has 4 module
All IntegrationTest cases are written in a separate module which has no source code only src/test/java folder.
All UnitTest are written in other 2 module inside src/test/java
4th module has responsibility to aggregate the report from all 3 module (2 modules that have Unit test and one module that has integration test)
Currently we are getting coverage from UnitTest only We want to include coverage from Integration test as well
SonarQube Version: * Community Edition* v10.6 (92116)
Jacoco Version:0.8.11
We are using following plugin for Unit test

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>

For Unit test we are using surefire plugin 3.0.0-M5

For Integration test we are fail-safe plugin 2.22.2

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<id>prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
</executions>
</plugin>

Aggregator module plugin

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>

We are able to see three files
2 files from Unit test jacoco.exec
1 file from jacoco-it.exec from integration test module
Aggregator is aggregating all three exec but somehow we are not able to see code coverage from Integration module.
Even if we remove jacoco-it.exec there is no change in code coverage percentage.
We also tried importing jacoco-it.exec in IntellijIdea editor but it show no coverage.
Following are the maven logs:

[**INFO**] **---** jacoco:0.8.11:report-aggregate **(report-aggregate)** @ jacoco-aggregate-report **---**

[**INFO**] Loading execution data file /Users/xyz/Documents/GitHub/geoff/target/jacoco.exec

[**INFO**] Loading execution data file /Users/xyz/Documents/GitHub/service/target/jacoco.exec

[**INFO**] Loading execution data file /Users/xyz/Documents/GitHub/integration-test/target/jacoco-it.exec

I am facing the same issue. Can someone please help on this

1 Like

I am also facing this issue. Can someone please help on this

1 Like

Hi all,

Welcome to the community!

Only the latest version of SonarQube Community Build is considered active, so you’ll need to upgrade and see if the situation is still replicable before we can help you.

Your upgrade path is:

10.6 → 25.3

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

Regarding your question, the exec JaCoCo format hasn’t been supported for a while now. You’ll need to switch to the XML report format.

 
HTH,
Ann

Thanks a lot
We will update version and keep it posted

1 Like