androidandroid-testingandroid-junit

Test Orchestrator Sample


Is anyone aware of a sample project that shows how to get test orchestrator working? I checked the google samples and there doesn't seem to be a good sample project that shows test orchestrator.

https://github.com/googlesamples/android-testing

I have been attempting to get android tests running in the test orchestrator but have been struggling to get it to work correctly. I tried both running the tests through Android Studio (latest 3.2.1) as well as the command line (https://developer.android.com/training/testing/junit-runner#ato-command-line). I used the Android developer document for reference.

https://developer.android.com/training/testing/junit-runner

Here are the steps I followed.

1) Create an empty activity application using the wizard in Android 
Studio 
2) Enable the test orchestrator using the steps provided here 
(https://developer.android.com/training/testing/junit-runner).
3) Run the unit tests from within the IDE and from the command line.

When I do this, I get an error indicating that my "test suite is empty". I get the same error running from command-line.

Note that if I run the test without test orchestrator, then the test runs successfully.

Also note that I am using the latest test orchestrator versions


Solution

  • The complete configuration to run test orchestrator:

    1. Add dependencies:

      androidTestImplementation "androidx.test:runner:$testRunner" androidTestUtil "androidx.test:orchestrator:$testOrchestrator"

    2. Add clear package instruction (within defaultConfig in app's build.gradle):

      //allows run all tests on an isolated way. If we need to debug a test, should disable this and the orchestrator testInstrumentationRunnerArguments clearPackageData: 'true'

    3. Add to testOptions Android/AndroidX orchestrator:

      testOptions { execution 'ANDROIDX_TEST_ORCHESTRATOR' }