SonarQube code coverage by JaCoCo

sonarqube
jacoco
(puci) #1
  • version: JaCoCo 1.0.1, SonarQube 7.4, SonarJava 5.10.2, Gradle 5.0
  • I would like to receive information about coverage per test from line. But in SonarQube report on green line indicated coveraged lines is written
    Covered by following tests:
    There is no extra information about test files.
  • Both junit test and percentage coverage information is displayed.
  • Here is my sonar setting:
// --- Coverage setting
property "sonar.java.coveragePlugin", "jacoco"
//property "sonar.jacoco.reportPaths", file("${project.certifyDir}/jacoco/allTestCoverage.exec")
property "sonar.junit.reportPaths", file("/tmp/common/build/test-results/unittests/")
property "sonar.coverage.jacoco.xmlReportPaths", file("${project.certifyDir}/reports/jacoco/jacocoMergedReport.xml")
property "sonar.it.reportPath", "mergedExecDir"
  • My dependencies:
useJUnit{
listeners org.sonar.java.jacoco.JUnitListener'
}
dependencies{
runtime'org.sonarsource.java:sonar-jacoco-listeners:3.8'
}
SonarQube Coverage per Test Information with ANT
(puci) #2

I’ve already found a solution, so if someone else fights with this bug, the solution is to set the coverage for each sub-module:

subprojects{
// --- Coverage setting
property "sonar.java.coveragePlugin", "jacoco"
//property "sonar.jacoco.reportPaths", file("${project.certifyDir}/jacoco/allTestCoverage.exec")
property "sonar.junit.reportPaths", file("/tmp/common/build/test-results/unittests/")
property "sonar.coverage.jacoco.xmlReportPaths", file("${project.certifyDir}/reports/jacoco/jacocoMergedReport.xml")
property "sonar.it.reportPath", "mergedExecDir"
}