Skip to content

Unable to generate code coverage reportΒ #96

Description

@fwpascual

πŸ‘“ What did you see?

When enabling code coverage, it fails to generate a code coverage report and fails the build

βœ… What did you expect to see?

A successful build and code coverage report

πŸ“¦ Which version are you using?

4.9.0

πŸ”¬ How could we reproduce it?

A sample project has been created to demonstrate the issue:
https://github.com/fwpascual/cucumber-coverage-sample

Steps to reproduce the behavior:

  1. Download the provided repo
  2. Run ./gradlew clean cAT
  3. See error in output.

The above project is based off of a sample from the Android test samples:
https://github.com/android/testing-samples/tree/main/runner/AndroidTestOrchestratorWithTestCoverageSample

πŸ€” Anything else?

I suspect the issue is in the android test framework, but logging here in case there's any ideas. The android-test repo issue can be found here:
android/android-test#1319

The following are some additional details:

Get a failure during the :app:createDebugAndroidTestCoverageReport gradle task

* What went wrong:
Execution failed for task ':app:createDebugAndroidTestCoverageReport'.
> A failure occurred while executing com.android.build.gradle.internal.coverage.JacocoReportTask$JacocoReportWorkerAction
   > Unable to generate Jacoco report

Inspecting the folder under app/build/outputs/code_coverage/debugAndroidTest/connected/Pixel_4_XL_API_31(AVD) - 12, I see a Sample\ Feature#Sample\ Scenario.ec file, but it's zero bytes. When I look for this same file on the emulator, I see the same file under /sdcard/googletest/internal_use/data/data/com.example.android.testing.androidtestorchestratorsample/coverage_data/Sample Feature#Sample Scenario.ec with a 123 byte file.

Running the :app:connectedDebugAndroidTest task, I don't get a failure, and at this point the .ec file is also in the above described emulator device folder, however, I see this error in the gradle build log:

> Task :app:connectedDebugAndroidTest
Starting 1 tests on Pixel_4_XL_API_31(AVD) - 12
Mar 14, 2022 1:18:07 PM com.android.tools.utp.plugins.host.coverage.AndroidTestCoveragePlugin deviceShellAndCheckSuccess
WARNING: Shell command failed (1): cat "/sdcard/googletest/internal_use///data/data/com.example.android.testing.androidtestorchestratorsample/coverage_data//Sample\ Feature#Sample\ Scenario.ec" > "/data/local/tmp/b57c2a44-ba36-473d-9edf-5441bd14c514-coverage_data/Sample\ Feature#Sample\ Scenario.ec"
cat: /sdcard/googletest/internal_use///data/data/com.example.android.testing.androidtestorchestratorsample/coverage_data//Sample\ Feature#Sample\ Scenario.ec: No such file or directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions