In my project, one of the subproject is NodeJS hence the usual Jacoco setup:
1
2
3
| tasks.withType(Test) {
finalizedBy jacocoTestReport
}
|
doesn’t work as Jacoco fails since it can’t locate test execution binary for the nodeJS project.
After some trial & error, found out this approch works:
1
2
3
4
5
6
| tasks.withType(Test).each { testTask ->
//nodeJS doesn't support jacoco
if(!testTask.getProject().toString().contains("nodejsproject")) {
testTask.finalizedBy(jacocoTestReport)
}
}
|
then add jacoco gradle setup as usual with executionData setup:
1
2
3
4
5
6
7
8
9
10
11
12
| apply plugin: 'jacoco'
jacocoTestReport {
executionData { tasks.withType(Test).findAll { it.jacoco.destinationFile.exists() }*.jacoco.destinationFile }
reports {
xml.enabled true
xml.destination(file("${jacoco.reportsDir}/xml/jacocoTestReport.xml"))
html.enabled true
html.destination(file("${jacoco.reportsDir}/html"))
}
}
|
credit to: https://stackoverflow.com/questions/19025138/gradle-how-to-generate-coverage-report-for-integration-test-using-jacoco