It is possible to feed SonarQube with tests execution and code coverage reports.
The Java Plugin is going to reuse reports and not generate them, so before trying to configure your analysis to import these reports, you need to be sure they are correctly generated and not empty.
- The tests execution reports have to comply to the JUnit XML format.
- The code coverage reports have to be generated with JaCoCo
You need to give the path of test execution and code coverage reports using the following parameters.
Import tests execution reports (Surefire XML format).
Set the property with a list of comma-separated paths to the directories containing the XML reports.
|sonar.jacoco.reportPaths||Project-wide||target/jacoco.exec, target/jacoco-it.exec (default)|
Import JaCoCo code coverage reports.
Set the property to the path of the JaCoCo .exec reports, merge multiple reports.
(if you are using a version of SonarQube prior to 6.2 please use sonar.jacoco.reportPath property)
Further details on using JaCoCo are available in Usage of JaCoCo with Java Plugin .
A note to Cobertura users
SonarJava does not support import of Cobertura coverage data. A sonar-cobertura plugin exists, however maintenance and support there is entirely community based. More generally speaking, also note that SonarQube provides a tool-agnostic generic solution: Generic Test Data .