How to configure JaCoCo (to exclude some source files) for Android project with isTestCoverageEnabled=true

238 Views Asked by At

The code coverage works perfectly fine for me when just set isTestCoverageEnabled = true in my BuildType Android Gradle configuration. It creates 2 tasks createReleaseUnitTestCoverageReport for release build type and createDebugUnitTestCoverageReport for debug one.

The issue that all source files appear in the report and I would like to exclude some of them - e.g. Dagger generated classes etc.

According to the Android docs the only configuration to change is

testCoverage {
    jacocoVersion = "YOUR JACOCO VERSION"
}

and nothing else.

Since there is no jacocoTestReport task all solutions from StackOverflow don't work.

Is there any decent way to configure JaCoCo for Android except creating a custom jacocoTestReport task?

0

There are 0 best solutions below