Monday, 8 November 2021

Exclude android Instrumentation tests while generating Jacoco report

I have multiple modules in Android application. I need to automate code coverage report in the CI/CD pipeline where it doesn’t have physical/virtual android device and not possible to attach a device.

Integrated Jacoco from - https://github.com/gouline/android-samples/blob/master/jacoco/jacoco.gradle

When I try to generate coverage report via gradle command

>> ./gradlew createDebugCoverageReport

It fails with the below error log

* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> com.android.builder.testing.api.DeviceException: No connected devices!

So I tried to exclude the gradle tasks (connectdDebugAndroidTest) via command

>> ./gradlew createDebugCoverageReport -x app:connectedDebugAndroidTest -x module1:connectedDebugAndroidTest

Getting error as below -

> Task :module1:createDebugAndroidTestCoverageReport FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':vpn:createDebugAndroidTestCoverageReport'.
> java.io.IOException: No coverage data to process in directories [/Users/abc/ws/prjName/module1/build/outputs/code_coverage/debugAndroidTest/connected]

I have instrumentation tests in the module1

How to exclude Instrumentation tests while generating Jacoco report when the device is not connected.

update:

I am able to generate Jacoco reports individually for each module via

./gradlew testDebugUnitTestCoverage

But I am looking for a integrated report. How to integrate multiple jacoco reports from modules into one report?



from Exclude android Instrumentation tests while generating Jacoco report

No comments:

Post a Comment