I am currently using a multi-module Java project with good coverage and sonarqube 6.2 with the sonarJava 4.10.0.1026 plugin. I am using Gradle 4.0.1, the sonarqube 2.5 plugin and jacoco 0.7.9! Java 8 code.
Due to API-based development, API tests are written as abstract tests in API projects and called from implementation projects that provide constructors for the tests.
When analyzing a project on the sonarqube server, the coverage for implementation projects is measured correctly, but the API projects included in the IMPL project tests have a coverage of 0.0%. The results of these projects are ignored.
Just using the jacoco plugin, I was able to get the same behavior. After doing some research, I found a solution to get the correct reports about yakoko:
task codeCoverageReport(type: JacocoReport) {
description "Creates a unified JaCoCo test report for the project."
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
subprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.enabled true
html.enabled true
html.destination file("${buildDir}/reports/jacoco")
csv.enabled false
}
}
codeCoverageReport.dependsOn {
subprojects*.test
}
:
JaCoCo:
- JaCoCo (codeCoverageReport-Task)
- 43,1% ( ~ 30% !)
- 82,1% ( ~ 20% !)
, . , "sonar.jacoco.reportPaths" -parameter, 6.2, , java-analyzer 4.4 sth. . gradle . jacoco.exec .
, .