Android Test Orchestrator 无法与 Android X 配合使用

标签 android android-espresso android-testing androidx androidx-test

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

相关文章:

java - 如何测试 InputMethodService

android - 如何单元测试 FragmentDialog 和实现接口(interface)的 Activity 之间的交互

java - Android Studio 和 java 编译器没有 SDK 常量

java - 如何在运行测试之前使异步作业的 JUnit4 "Wait"完成

android - 方法 findViewById(int) 未定义

Android Espresso 测试套件

android - 如何避免每次运行 Espresso 时出现 'Gradle build'

android - java.lang.IllegalStateException : Cancel call cannot happen without a maybeRun

java - 为什么列表大小返回0?

android - 如何将对话框窗口背景设置为透明,而不影响其边距