Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.



titleTable of Contents

Table of Contents

Code Coverage by Integration Tests


Java Projects

To get the code coverage by integration tests on your project, you should simply follow the 5 steps below:

  1. Attach and configure a JaCoCo agent to the JVM which you will run your integration tests with. To do so, have a look at the detailed JaCoCo documentation to attach the agent: via a command line, using the JaCoCo Maven plugin or using the JaCoCo Ant task.
  2. Run your automated or manual integration tests within this JVM. At the end of the execution, JaCoCo will dump the code coverage report in the destination you have set in step 1.
  3. Configure Sonar to reuse this JaCoCo report. In your project properties file (or directly in the command line), add the sonar.jacoco.itReportPath property with the path to the JaCoCo IT coverage report as a value.
  4. Run an analysis to feed Sonar with the information provided by the JaCoCo report.
  5. Browse the results on the Sonar web interface. On project dashboard, you can add the Integration test coverage widget:

    As usual, drilldown is available from this widget. At file level, you can access detailed code coverage by integration tests on the Coverage tab:

Note: You can still use Clover, Cobertura or Emma to assess code coverage by unit tests together with JaCoCo for integration tests.

Sample projects are available on github that can be browsed or downloaded: /projects/code-coverage/it.

Non-Java Projects

The following languages support importing code coverage by integration tests:

Browse the documentation of the plugin for more details.

Combining Code Coverage by Unit and Integration Tests

Since Sonar 3.3, Sonar automatically computes the overall code coverage (combination of code coverage by unit tests and integration tests). This feature is enable when both code coverage reports are generated with JaCoCo.


  • /projects/code-coverage/combined ut-it/combined-ut-it-sonar-runner-jacoco
  • /projects/code-coverage/combined ut-it/combined-ut-it-multimodule-maven-jacoco


See also the Measure Coverage by Integration Tests with Sonar – Updated blog post.