I am working on a project where in we are trying to use the ANDROID TEST ORCHESTRATOR for it's obvious benefits of isolating crashes. But while executing the test suite, it appears to me that as the orchestrator initiates a new process for every test case, the test coverage report for the suite execution is always showing incomplete data (mostly the data for the last test case present in the test suite).
So I was wondering that is there a way to overcome this problem and generate a jacoco code coverage report for all instrumented tests existing in the test suite.
Android Studio has a built-in feature that allows you to run tests with code coverage. Simply navigate to the src/test/java folder and right click. Then select Run 'Tests in 'java'' with Coverage (awkward use of single quotes theirs not mine).
When you use AndroidJUnitRunner to run your tests, you can access the context for the app under test by calling the static ApplicationProvider. getApplicationContext() method. If you've created a custom subclass of Application in your app, this method returns your custom subclass's context.
Test orchestration means setting up a well-defined sequence of automated test activities. For example, at the end of a development sprint, when software is marked as ready for release, there are several activities performed before the software reaches its end users or business users.
If you're using the android test orchestrator this is the problem. There is an open bug report: https://issuetracker.google.com/issues/72758547
The only solution that I know of is to disable the android test orchestration until a fix is released.
In my Android Java build.gradle
I had to comment out the test orchestrator like so:
android {
...
testOptions {
// temporarily disable the orchestrator as this breaks coverage: https://issuetracker.google.com/issues/72758547
//execution 'ANDROID_TEST_ORCHESTRATOR'
...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With