Test Orchestrator示例

问题描述 投票:0回答:1

是否有人知道示例项目如何让测试协调器工作?我检查了谷歌样本,似乎没有一个好的示例项目显示测试协调器。

https://github.com/googlesamples/android-testing

我一直试图在测试协调器中运行android测试,但一直在努力让它正常工作。我尝试通过Android Studio(最新的3.2.1)以及命令行(https://developer.android.com/training/testing/junit-runner#ato-command-line)运行测试。我使用Android开发人员文档作为参考。

https://developer.android.com/training/testing/junit-runner

以下是我遵循的步骤。

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.

当我这样做时,我收到一个错误,表明我的“测试套件是空的”。我从命令行运行同样的错误。

请注意,如果我在没有test orchestrator的情况下运行测试,那么测试将成功运行。

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

android android-testing android-junit
1个回答
1
投票

运行测试orchestrator的完整配置:

  1. 添加依赖项: androidTestImplementation“androidx.test:runner:$ testRunner”androidTestUtil“androidx.test:orchestrator:$ testOrchestrator”
  2. 添加clear package指令(在app的build.gradle中的defaultConfig中): //允许以隔离的方式运行所有测试。如果我们需要调试测试,应该禁用它和orchestrator testInstrumentationRunnerArguments clearPackageData:'true'
  3. 添加到testOptions Android / AndroidX orchestrator: testOptions {execution'ANDROIDX_TEST_ORCHESTRATOR'}
© www.soinside.com 2019 - 2024. All rights reserved.