Android 测试编排器示例

Android 测试编排器示例,android,android-testing,android-junit,Android,Android Testing,Android Junit,是否有人知道一个示例项目,它展示了如何让测试编排器工作?我检查了google示例,发现似乎没有一个好的示例项目显示TestOrchestrator 我一直在尝试让android测试在测试编排器中运行,但一直在努力让它正常工作。我尝试通过AndroidStudio(最新版本3.2.1)和命令行()运行测试。我使用Android开发者文档作为参考 以下是我遵循的步骤 1) Create an empty activity application using the wizard in Andro

是否有人知道一个示例项目,它展示了如何让测试编排器工作?我检查了google示例,发现似乎没有一个好的示例项目显示TestOrchestrator

我一直在尝试让android测试在测试编排器中运行,但一直在努力让它正常工作。我尝试通过AndroidStudio(最新版本3.2.1)和命令行()运行测试。我使用Android开发者文档作为参考

以下是我遵循的步骤

1) Create an empty activity application using the wizard in Android 
Studio 
2) Enable the test orchestrator using the steps provided here 
(https://developer.android.com/training/testing/junit-runner).
3) Run the unit tests from within the IDE and from the command line.
当我这样做时,我得到一个错误,指示我的“测试套件是空的”。我从命令行运行时也会遇到同样的错误

请注意,如果在没有测试编排器的情况下运行测试,那么测试将成功运行

还要注意,我使用的是最新的测试编排器版本

  • 测试编排器()
  • 测试服务()

运行测试编排器的完整配置:

  • 添加依赖项:

    androidTestImplementation“androidx.test:runner:$testRunner” androidTestUtil“androidx.test:orchestrator:$testOrchestrator”

  • 添加清除包指令(在应用程序的build.gradle中的defaultConfig中):

    //允许以隔离方式运行所有测试。如果我们需要调试一个测试,应该禁用它和orchestrator TestInstrumentRunNerguments clearPackageData:“真”

  • 添加到testOptions Android/AndroidX orchestrator:

    测试选项{ 执行“ANDROIDX\u测试\u编排器” }


  • 你是否在你的build.gradle中使用了“ANDROIDX\u TEST\u ORCHESTRATOR”(带X)?谢谢@tobltobs。这就是我的问题:)由于某种原因,我查看的样本缺少“X”。