我最近将我的项目迁移为使用 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/59309466/