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