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.
When you use AndroidJUnitRunner to run your tests, you can access the context for the app under test by calling the static ApplicationProvider. getApplicationContext() method. If you've created a custom subclass of Application in your app, this method returns your custom subclass's context.
AndroidJUnit4 is the class test runner. This is the thing that will drive the tests for a single class. You annotate your test classes with this: @RunWith(AndroidJUnit4. class) public class MyActivityTest { ... }
Android Test Orchestrator is a tool which allows you to run each of your app's tests within its own invocation of Instrumentation. This means that each test (method annotated with @Test ) will be run on a separate instance of AndroidJUnitRunner.
Unit tests or small tests only verify a very small portion of the app, such as a method or class. End-to-end tests or big tests verify larger parts of the app at the same time, such as a whole screen or user flow. Medium tests are in between and check the integration between two or more units.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With