Reputation: 1066
Jacoco fails to generate a code coverage report if the tests fail.
Below is the relevant section of my gradle file:
task unitTest(type: Test) {
forkEvery = 1
jvmArgs = ['-Djava.net.preferIPv4Stack=true']
testClassesDir = sourceSets.unitTest.output.classesDir
classpath = sourceSets.unitTest.runtimeClasspath
exclude '**/**TestBase.*'
outputs.upToDateWhen { false }
ignoreFailures = true
finalizedBy jacocoTestReport
}
task functionalTest(type: Test) {
forkEvery = 1
jvmArgs = ['-Djava.net.preferIPv4Stack=true']
testClassesDir = sourceSets.functionalTest.output.classesDir
classpath = sourceSets.functionalTest.runtimeClasspath
exclude '**/**TestBase.*'
outputs.upToDateWhen { false }
}
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/reports/jacoco/html"
}
executionData = files('build/jacoco/test.exec')
}
Even though I have specified the "ignoreFailures=true", there is no code coverage report after the test run.
There were failing tests. See the report at: file:///unitTest/index.html
:MYModule:jacocoTestReport SKIPPED
BUILD SUCCESSFUL
Total time: 41 mins 34.018 secs
Upvotes: 0
Views: 969
Reputation: 1066
The issue was that the executionData was pointing to a wrong "test.exec". It should have been "unitTest.exec", named after the test task that was being executed.
Upvotes: 1