I'm using Robolectric
and JaCoCo
together. My code coverage reports do not work without the following lines of code in gradle script:
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
But in the recent version of Gradle the JaCoCo extension, that I use here, is marked as deprecated. I could not find any replacement for it. So, where should I apply the includeNoLocationClasses = true
option?
JaCoCo Report configurationThe JacocoReport task can be used to generate code coverage reports in different formats. It implements the standard Gradle type Reporting and exposes a report container of type JacocoReportsContainer.
Using the Gradle Kotlin DSL with Gradle 5.5.1
and Kotlin 1.3.31
this works:
tasks {
withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = true
}
}
}
I found a solution. JaCoCo automatically adds jacoco
extension to all tasks of test
type. So, all that I had to do was adding the following lines into build script:
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
It doesn't look like an official solution, but it allows the custom JacocoReport
implementation to work correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With