How to run with the Android Test Orchestrator from Android Studio IDE instead of command line

1k views Asked by At

I would like my tests to use the Android Test Orchestrator when I run from Android Studio but the documentation only describes running it from the command line:

./gradlew connectedCheck

I prefer to run from Android Studio where I can simply press the play button next to a test and it runs just that test. I believe Android Studio generates what it calls a "Run/Debug Configuration" for the test. I believe a Debug Configuration is needed in order to set breakpoints in the test code and/or breakpoints for the code associated with the system under test--I assume breakpoints don't work when you run from the command line.

But does the Run/Debug Configuration employ the Android Test Orchestrator? From my testing it does not appear to because my app only asks for permissions on a wiped emulator. I believe the emulator is retaining granted permissions across runs which the Android Test Orchestrator is not supposed to do.

I looked at the Run/Debug Configuration Android Studio generated when I tapped the play button. It seems like it's using the Android Test Orchestrator because the configuration panel "General" shows the following options:

Instrumentation class: androidx.test.runner.AndroidJUnitRunner Instrumentation arguments: clearPackageData true

On the configuration panel "Miscellaneous" I found under "Installation Options" the option "Skip installation if APK has not changed". It was selected by default. I tried unselecting it but that didn't clear the permissions on my emulator.

How do I make Android Studio's Run/Debug Configuration employ the Android Test Orchestrator?

I looked for others who've asked this question but couldn't find this specific answer.

1

There are 1 answers

0
Sameer Technomark On

As per the current Android Developer AndroidJUnitRunner docs the steps to making Android Studio's test play buttons use Android Test Orchestrator work for me i.e. add the lines of code to your build config.