Android Test Orchestrator not working with Android X
Asked Answered
L

3

21

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.

Ligialignaloes answered 11/10, 2018 at 11:54 Comment(0)
L
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.

Ligialignaloes answered 11/10, 2018 at 11:54 Comment(6)
Intuitively obvious to the casual observer. JK -- if I could give you more up arrows I would.Colloquium
When switching to ANDROIDX_TEST_ORCHESTRATOR, I am getting Unknown Execution value 'ANDROIDX_TEST_ORCHESTRATOR'. Possible values are 'host', 'android_test_orchestrator'.German
I am getting the same exception @MarkHan - did you figure it out?Deadlight
Perhaps updating to classpath 'com.android.tools.build:gradle:3.2.1' fixed it for me. What version are you using? @DeadlightGerman
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.Jacquelinejacquelyn
You have to be using Gradle Build Tools 3.2.1 to recognise ANDROIDX_TEST_ORCHESTRATORRonna
G
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).

Groggy answered 4/3, 2019 at 23:33 Comment(0)
R
-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

Rudolphrudwik answered 13/12, 2019 at 15:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.