Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coverage for android tests using orchestrator

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.

like image 708
Shredder Avatar asked Jan 01 '18 20:01

Shredder


People also ask

How do I get code coverage on Android?

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).

Why do you use the Android Unitrunner when running UL tests?

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.

What is test orchestrator?

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.


1 Answers

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'
    ...
    }
}
like image 133
Inti Avatar answered Oct 03 '22 13:10

Inti