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/52759444/

相关文章:

javascript - 大约 2 分钟后,Webaudio 声音在 Chrome for Android 上停止

没有开始 Activity 的android putextra

android - 如何在 Android 仪器测试中删除应用程序的同步帐户

android - 安装的测试 APK 没有出现在设备的主屏幕上

android - uses-permission 权限的单元测试

android - 如何在 Android 中使用 Lisp?

javascript - 如何强制移动浏览器为输入类型 ="text"拉出数字键盘?

android - 如何使用 Espresso 计数 RecyclerView 项目

android-testing - 库模块 'com.android.library' 中的 Espresso 测试

android - 如何使用 ActivityInstrumentationTestCase2 捕获异常?