20

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.

Jin
  • 12,748
  • 3
  • 36
  • 41
FlashAsh80
  • 1,357
  • 1
  • 16
  • 27

3 Answers3

35

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.

FlashAsh80
  • 1,357
  • 1
  • 16
  • 27
  • 1
    Intuitively obvious to the casual observer. JK -- if I could give you more up arrows I would. – JohnnyLambada Oct 16 '18 at 23:43
  • 2
    When switching to ANDROIDX_TEST_ORCHESTRATOR, I am getting `Unknown Execution value 'ANDROIDX_TEST_ORCHESTRATOR'. Possible values are 'host', 'android_test_orchestrator'.` – Mark Han Nov 14 '18 at 21:47
  • I am getting the same exception @MarkHan - did you figure it out? – dazza5000 Nov 14 '18 at 23:43
  • 1
    Perhaps updating to `classpath 'com.android.tools.build:gradle:3.2.1'` fixed it for me. What version are you using? @dazza5000 – Mark Han Nov 16 '18 at 16:44
  • When switching to ANDROIDX_TEST_ORCHESTRATOR, I am getting the error `Cannot convert string value 'ANDROIDX_TEST_ORCHESTRATOR' to an enum value of type 'com.android.builder.model.TestOptions$Execution' (valid case insensitive values: HOST, ANDROID_TEST_ORCHESTRATOR)`. Updating `com.android.tools.build:gradle` did not fix that. – Akhil Tiwari Dec 03 '18 at 06:52
  • You have to be using Gradle Build Tools 3.2.1 to recognise ANDROIDX_TEST_ORCHESTRATOR – Eurig Jones Dec 19 '18 at 16:50
1

For anyone else struggling with the Cannot convert string value 'ANDROIDX_TEST_ORCHESTRATOR' to an enum value of type 'com.android.builder.model.TestOptions$Execution' (valid case insensitive values: HOST, ANDROID_TEST_ORCHESTRATOR) error message, ANDROIDX_TEST_ORCHESTRATOR seems to be incompatible with the latest version of IntelliJ (2018.3.5), it worked fine in Android Studio (3.3.2).

-1

Anyone with Complex projects - here are my gradle changes

repositories {
mavenCentral()
flatDir {
    dirs 'aars'
}
maven {
    url "https://maven.google.com"
}
google()}


testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


dependencies {
compile 'androidx.lifecycle:lifecycle-extensions:2.0.0'
compile 'androidx.core:core:1.0.0'
compile 'androidx.recyclerview:recyclerview:1.0.0'
compile 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.multidex:multidex:2.0.0'
//kapt 'androidx.databinding:databinding-compiler:1.0.0'
androidTestImplementation('androidx.test:runner:1.1.0', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('androidx.test:rules:1.1.0', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestUtil 'androidx.test:orchestrator:1.1.0'
implementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
// Espresso support
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('androidx.test.espresso:espresso-intents:3.1.0', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('androidx.test.espresso:espresso-web:3.1.0', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile('androidx.room:room-runtime:2.0.0', {
    exclude group: 'com.android.support'
})
kapt 'androidx.room:room-compiler:2.0.0'
compile('androidx.room:room-rxjava2:2.0.0', {
    exclude group: 'com.android.support'
})
testCompile('androidx.room:room-testing:2.0.0', {
    exclude group: 'com.google.code.gson'
})
androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0') {
    exclude group: 'com.android.support', module: 'appcompat'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude module: 'recyclerview-v7'
}
compile 'androidx.exifinterface:exifinterface:1.0.0'}


       classpath 'com.android.tools.build:gradle:3.4.1'

rest of the errors I had to fix manually but in the end it worked

cindy
  • 476
  • 6
  • 8