Search code examples
androidandroid-espressoandroid-testingandroidxandroidx-test

Android Test Orchestrator not working with Android X


I have recently migrated my project to use AndroidX, and have configured test orchestrator for my espresso tests on gradle using the following docs:

https://developer.android.com/training/testing/junit-runner#using-android-test-orchestrator

I have the dependency:

androidTestUtil 'androidx.test:orchestrator:1.1.0-beta01'

However, none of my tests are executed and looks like they fail when running gradle runs the following adb shell command i.e:

adb shell 'CLASSPATH=$(pm path android.support.test.services) app_process / \
  android.support.test.services.shellexecutor.ShellMain am instrument -w -e \
  targetInstrumentation com.example.test/androidx.test.runner.AndroidJUnitRunner \
  android.support.test.orchestrator/.AndroidTestOrchestrator'

from looking at the above: It seems like it is trying to execute this command with android support version as opposed to the androidx version.

It doesn't seem to be documented anywhere what to use for androidx.


Solution

  • Purely by guessing, I changed the following in my gradle config

    from:

      testOptions {
        execution 'ANDROID_TEST_ORCHESTRATOR'
      }
    

    to

      testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
      }
    

    and all seems to work.