Reputation: 3662
We have a gradle project with mutliple modules - so each module - eg admin, ends up having something like this:
task admintest(type: Test) {
description = "Tests of admin"
testClassesDir = sourceSets.admintest.output.classesDir
classpath += sourceSets.admintest.runtimeClasspath
}
check.dependsOn admintest
now - we are generating a jacoco report - the report actually includes all the classes from all the different modules, but only has coverage from the tests that ran as part of the main module, ie the "test" task - while the admintests and others run, the coverage is always zero. How do I get jacoco to also pick up the coverage from the admintests, and other module tests?
Upvotes: 3
Views: 2678
Reputation: 530
This is old thread , but this might help someone :
We only need this in build.gradle of root project.
Define a common location
Provide same to sonarqube as well.
plugins {
..
id "org.sonarqube"
}
apply plugin: 'org.sonarqube'
allprojects {
apply plugin: 'jacoco'
}
task jacocoRootReport(type: JacocoReport) {
dependsOn = subprojects.test
description = 'Generates aggregate report from all subprojects.'
.....
reports {
xml.enabled true
xml.destination(file("${jacoco.reportsDir}/all-tests/jacocoRootReport.xml"))
csv.enabled false
}
}
sonarqube {
properties {
property "sonar.coverage.jacoco.xmlReportPaths", jacocoRootReport.reports.xml.destination
}
}
Upvotes: 0
Reputation: 3662
Found it - for those who are trying to do this - the secret sauce is to specify the other modules test tasks in the executionData
eg:
jacocoTestReport {
executionData test, admintest, commontest
}
Upvotes: 1