我最近将我的项目迁移到使用 AndroidX,并使用以下文档为我在 gradle 上的 espresso 测试配置了测试协调器:
https://developer.android.com/training/testing/junit-runner#using-android-test-orchestrator
我有依赖:
androidTestUtil 'androidx.test:orchestrator:1.1.0-beta01'
但是,我的测试都没有执行,看起来它们在运行 gradle 时运行以下 adb shell 命令时失败,即:
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'
从上面看:它似乎正在尝试使用 android 支持版本而不是 androidx 版本执行此命令。
在任何地方似乎都没有记录在 androidx 上使用什么。
最佳答案
纯靠猜测,我在我的gradle配置中更改了以下内容
来自:
testOptions {
execution 'ANDROID_TEST_ORCHESTRATOR'
}
到
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
一切似乎都有效。
关于Android Test Orchestrator 不适用于 Android X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52759444/