有人知道一个示例项目,该示例项目说明了如何使测试协调器正常工作吗?我检查了google示例,似乎没有一个很好的示例项目可以显示测试协调器。
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.
执行此操作时,出现错误,指示我的“测试套件为空”。我从命令行运行时遇到相同的错误。
请注意,如果我在没有测试协调器的情况下运行测试,则测试将成功运行。
还请注意,我正在使用最新的测试协调器版本
答案 0 :(得分:1)
运行测试协调器的完整配置:
添加依赖项:
androidTestImplementation“ androidx.test:runner:$ testRunner” androidTestUtil“ androidx.test:orchestrator:$ testOrchestrator”
添加清晰的软件包说明(在应用程序的build.gradle中的 defaultConfig 中):
//允许以隔离的方式运行所有测试。如果我们需要调试测试,则应禁用此功能以及协调器 testInstrumentationRunnerArguments clearPackageData:'true'
添加到testOptions Android / AndroidX协调器:
testOptions { 执行“ ANDROIDX_TEST_ORCHESTRATOR” }