# Jacoco unit and integration tests code coverage

**URL:** <https://community.sonarsource.com/t/jacoco-unit-and-integration-tests-code-coverage/48232>\
**Category:** SonarQube Server / Community Build\
**Created:** [August 17, 2021, 2:39pm UTC](https://community.sonarsource.com/t/jacoco-unit-and-integration-tests-code-coverage/48232 "2021-08-17T14:39:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![macgeek](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@macgeek](https://community.sonarsource.com/u/macgeek)\
**Post date:** [August 17, 2021, 2:39pm UTC](https://community.sonarsource.com/t/jacoco-unit-and-integration-tests-code-coverage/48232/1 "2021-08-17T14:39:10Z")

</div>

Hello,

We are using sonarqube version 8.9 and jacoco-maven-plugin version 0.8.7.  
We also use maven-sueerfire-plugin for unit tests and maven-failsafe-plugin for integration tests.

Maven config is the following:

\<jacoco.version\>0.8.7\</jacoco.version\>  
\<sonar.java.coveragePlugin\>jacoco\</sonar.java.coveragePlugin\>  
\<sonar.dynamicAnalysis\>reuseReports\</sonar.dynamicAnalysis\>  
\<sonar.language\>java\</sonar.language\>  
\<sonar.coverage.jacoco.xmlReportPaths\>target/site/jacoco/jacoco.xml, target/site/jacoco-it/jacoco.xml\</sonar.coverage.jacoco.xmlReportPaths\>

org.jacoco jacoco-maven-plugin ${jacoco.version} prepare-agent prepare-agent-integration report report-integration 

The reported coverage in sonarqube seems to be showing the combined coverage of both unit and integration tests. However in the left menu, I can only see Unit Tests, when I click on this link I can see the number of unit tests. Is it also possible to show the number of integration tests ? Why are they not all together so we can have a full overview of test classes ?

Thanks,  
Lucas

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 17, 2021, 7:00pm UTC](https://community.sonarsource.com/t/jacoco-unit-and-integration-tests-code-coverage/48232/2 "2021-08-17T19:00:01Z")

</div>

Hi,

Welcome to the community!

> [@macgeek](#):
>
> The reported coverage in sonarqube seems to be showing the combined coverage of both unit and integration tests.

Yes, coverage from all types is aggregated.

> [@macgeek](#):
>
> However in the left menu, I can only see Unit Tests, when I click on this link I can see the number of unit tests. Is it also possible to show the number of integration tests ?

This is labeled Unit Tests because that’s typically what the reports about the tests themselves cover. There’s not a way to have a second set of numbers that’s just about your ITs.

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![macgeek](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@macgeek](https://community.sonarsource.com/u/macgeek)\
**Post date:** [August 17, 2021, 8:45pm UTC](https://community.sonarsource.com/t/jacoco-unit-and-integration-tests-code-coverage/48232/3 "2021-08-17T20:45:20Z")

</div>

> [@ganncamp](#):
>
> This is labeled Unit Tests because that’s typically what the reports about the tests themselves cover. There’s not a way to have a second set of numbers that’s just about your ITs.

Hello Ann,

Thank you for your answer, however when I look under unit tests, I only see the unit tests listed, not the integration tests. Maybee it’s a detail but just want to make sure the coverage is accurate.

Kind regards,  
Lucas

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 18, 2021, 1:55pm UTC](https://community.sonarsource.com/t/jacoco-unit-and-integration-tests-code-coverage/48232/4 "2021-08-18T13:55:34Z")

</div>

Hi Lucas,

Coverage doesn’t have a lot to do with the test execution report.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![bgranier](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@bgranier](https://community.sonarsource.com/u/bgranier)\
**Post date:** [October 18, 2023, 4:03pm UTC](https://community.sonarsource.com/t/jacoco-unit-and-integration-tests-code-coverage/48232/5 "2023-10-18T16:03:54Z")

</div>

Hi,  
I observed the same effect than Lucas did.

Does the anwser to his question change ?

I use Jacoco 0.8.10, maven-failsafe-plugin 3.1.2, maven-surefire-plugin 3.1.2, sonar-maven-plugin 3.10.0.2594, maven 3.8.6, open jdk 19, sonar sonarqube-10.2.1.78527.zip

---

<div class="post-metadata">

**Author:** ![bgranier](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@bgranier](https://community.sonarsource.com/u/bgranier)\
**Post date:** [October 18, 2023, 4:41pm UTC](https://community.sonarsource.com/t/jacoco-unit-and-integration-tests-code-coverage/48232/6 "2023-10-18T16:41:01Z")

</div>

I found a work around but it would be better to use the failsafe plugin.

The work around is to configure the surefire plugin to include \*\*/\*Test.java and \*\*/\*IT.java files and to use the build-helper-maven-plugin and to add src/it/java as test sources.
