It is possible to feed SonarQube with tests execution and code coverage reports.
See Component Viewer on Unit Test File or Quality Flows > Lack of Unit Tests to browse the results in the web interface.
To be reused by SonarQube:
You can check the page of each coverage plugin to get more information on how to generate the reports or you can check the Analyzing with Maven documentation.
If you use JaCoCo and define
When no reports are found, coverage value is not set. This behaviour can be overriden by a property for JaCoCo, please check the JaCoCo plugin page to see how.
You can set the following properties to import those reports:
# Import tests execution reports (JUnit XML format). # Set the property to the path of the directory containing all the XML reports. sonar.junit.reportsPath=target/surefire-reports # Import JaCoCo code coverage report. # Set the property to the path of the JaCoCo .exec report. sonar.jacoco.reportPath=target/jacoco.exec # Import Cobertura code coverage report. # Set the property to the path of the Cobertura .ser report. sonar.cobertura.reportPath=target/site/cobertura/coverage.xml # Import Clover code coverage report. # Set the property to the path of the Clover .xml report. sonar.clover.reportPath=target/clover.xml # For versions of the Java plugin prior to 2.2, the following properties have to be set as well. sonar.dynamicAnalysis=reuseReports sonar.java.coveragePlugin=plugin # either jacoco or cobertura or clover
Project samples are available on github that can be browsed or downloaded: projects/languages/java/code-coverage/ut