jacoco-android-gradle-plugin icon indicating copy to clipboard operation
jacoco-android-gradle-plugin copied to clipboard

Add support for Instrumentation test execution data

Open nikhil-thakkar opened this issue 5 years ago • 2 comments

Thanks for fixing the lib for Gradle 6.x 🎉

Could you add the execution data (.ec) files to the jacoco report task. This is because the code coverage for Instrumentation tests is not currently being reported by Jacoco.

I have the following workaround for now:

afterEvaluate {
       val task = tasks.getByName("jacocoTestDebugUnitTestReport") as JacocoReportBase
       val tree = fileTree(buildDir)
       tree.include("**/*.ec")
       task.executionData(tree)
}

nikhil-thakkar avatar Jun 09 '20 19:06 nikhil-thakkar

Here is a better version for kotlin based DSL

afterEvaluate {
        tasks.withType<JacocoReport>().run {
            all {
                val tree = fileTree(buildDir)
                tree.include("**/*.ec")
                executionData(tree)
            }
        }
    }

nikhil-thakkar avatar Jun 11 '20 07:06 nikhil-thakkar

I can confirm that workaround works. @nikhil-thakkar thanks.

I can now integrate Cucumber test with https://sonarcloud.io :+1:

my workaround:

afterEvaluate {
    def task = tasks.getByName("jacocoTestDebugUnitTestReport") as JacocoReportBase
    def tree = fileTree(buildDir)
    tree.include("**/*.ec")
    task.executionData(tree)
}

mercuriete avatar Feb 21 '21 14:02 mercuriete