I'm working in a multi-module Android project with an application module and a library module. If I simply add

apply plugin: 'jacoco'
jacoco {
     toolVersion '0.8.7'
}

to the build.gradle for each module, then when I run the off-device unit tests from the command line in each module's directory, I see an .exec file created at build/jacoco/testDebugUnitTest.exec with a size of ~27k or so. Generating a report from this does what I'd expect.

If I add

buildTypes {
    debug {
        testCoverageEnabled true
    }
}

to the build.gradle for each module (so that I can later gather coverage numbers for on-device tests as well) then when I run the off-device unit tests the .exec file is instead created in build/outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec.

More importantly, while that file is still ~27k when I'm running the tests in the application module, it is almost empty (only 45 bytes) when I'm running the tests in a library module in the same project.

Is there a reason testCoverageEnabled interferes with off-device code coverage for library modules but not for the primary application module?

0

There are 0 best solutions below