Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task combinedTestReport not showing instrumented coverage #191

Open
dsuresh-ap opened this issue Mar 16, 2021 · 3 comments
Open

Task combinedTestReport not showing instrumented coverage #191

dsuresh-ap opened this issue Mar 16, 2021 · 3 comments

Comments

@dsuresh-ap
Copy link

I feel like this might be related to #138

Running the combinedTestReport command generates the jacocoCombined report directory and files, however it does not contain any coverage on instrumented tests.

However if I check reports/coverage/**/ (generated by the createDebugCoverageReport task) I see the instrumented coverage there. It seems like the plugin task create the combined report isn't working.

I am using the 0.17 snapshot.

@dsuresh-ap
Copy link
Author

I think I found the issue. Not sure if its because of how our project is setup but I had to change the logic (also migrated the plugin to Kotlin)

if (combined) {
    // add instrumentation coverage execution data
    doFirst {
        def instrumentationTestCoverageDirs = subProject.fileTree("${subProject.buildDir}/outputs/code_coverage")
                .matching { include "**/*.ec" }
        def allCodeCoverageFiles = instrumentationTestCoverageDirs.files + executionData.files
        subProject.logger.with {
            info("using following code coverage files for ${taskName}")
            allCodeCoverageFiles.each { coverageFile ->
                info(coverageFile.path)
            }
        }
        executionData.setFrom(allCodeCoverageFiles)
    }
}

to (in Kotlin)

if (combined) {
    executionData.setFrom(
        subProject.fileTree(
            mapOf(
                "dir" to project.buildDir,
                "includes" to listOf(
                    "jacoco/test${sourceName.capitalize()}UnitTest.exec",
                    "outputs/code_coverage/${sourceName}AndroidTest/connected/**/*.ec"
                )
            )
        )
    )
}

For some reason executionData.setFrom(allCodeCoverageFiles) does not work with the current logic. Running combinedTestReport<> --info shows the following logs. Note the missing of .ec files. With my modified logic I see both coverage files.

[ant:jacocoReport] Loading execution data file s/app/build/jacoco/testDevelopmentDebugUnitTest.exec
[ant:jacocoReport] Loading execution data file s/app/build/outputs/code_coverage/developmentDebugAndroidTest/connected/android_emulator_30(AVD) - 11-coverage.ec

but with the plugin I only see ANT loading the .exec file.

@vanniktech
Copy link
Owner

Personally, I've never used the combine task. Do you care to submit a PR?

@dsuresh-ap
Copy link
Author

I can but not anytime soon since the project is setup to use the re-written plugin.

The change is really simple as you can see in my previous post but I am not sure if there is a reason why the original code does the following:

def instrumentationTestCoverageDirs = subProject.fileTree("${subProject.buildDir}/outputs/code_coverage")
     matching { include "**/*.ec" }
def allCodeCoverageFiles = instrumentationTestCoverageDirs.files + executionData.files
executionData.setFrom(allCodeCoverageFiles)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants