什么是Android Test Orchestrator? [英] What is Android Test Orchestrator?

查看:313
本文介绍了什么是Android Test Orchestrator?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google最近发布了Android测试支持库1.0.阅读概述之后,我对Android Test Orchestrator有点困惑.

Google released Android Testing Support Library 1.0 recently. After reading the overview, I'm a little confused with Android Test Orchestrator.

通常,AndroidJUnitRunner在同一检测过程中运行所有测试,这可能会导致许多问题.

Typically, AndroidJUnitRunner runs all tests in the same instrumentation process, which can cause a number of problems.

您能解释一下使用相同的检测过程会导致哪些类型的问题吗?

Can you explain which kinds of problems will be caused by using the same instrumentation process?

如果一个测试崩溃,它将阻止其余测试套件运行

if one test crashes, it prevents the remainder of the test suite from running

根据我的经验,一次测试崩溃不会阻止其他测试用例的运行.请指出我在这里误解了吗?

Through my experience, one test crash won't prevent from other test cases from running. Please point out what I misunderstood here?

并从 Android测试Orchestrator开发人员指南

为了完整起见,Android Test Orchestrator在每次测试后均以pm clear运行.

For completeness, Android Test Orchestrator runs pm clear after each test.

因此,Android Test Orchestrator将在每次测试后运行 pm clear [test_package_name] ,对吗?

So Android Test Orchestrator will run pm clear [test_package_name] after each test, right?

通过我的测试,每次测试后将不会执行 pm clear [app_package_name] .这意味着将不会清除正在测试的应用程序的数据.因此,测试用例可能仍然彼此依赖.例如:

Through my test, pm clear [app_package_name] won't be executed after each test. That means the data of application under test will not be cleared. So test cases might still have dependencies on each other. For example:

  • 测试用例A存储一个SharedPreference键值
  • 在测试用例A之后运行的测试用例B可以读出由测试用例A存储的值

总的来说,经过一番试用后,我发现Android Test Orchestrator没有任何优势.有人可以帮助解决我的困惑吗?谢谢.

Overall, after some trial, I did not find any advantage of Android Test Orchestrator. Can somebody help to address my confusion? Thanks.

推荐答案

在对问题进行了一点研究之后,我可以提供以下答案:

After researching the issue a bit I can provide the following answers:

通常,AndroidJUnitRunner在同一检测过程中运行所有测试,这可能会导致许多问题.

Typically, AndroidJUnitRunner runs all tests in the same instrumentation process, which can cause a number of problems.

如上所述,AndroidJUnitRunner在相同的检测过程上运行,因此基本上您的测试在全状态下运行,如果您的测试对进程状态有某种依赖性,则这可能会造成严重破坏.在Android测试协调器中,每个测试都是在自己的流程中运行的,因此依赖关系不会成为问题.

As mentioned, AndroidJUnitRunner runs on the same instrumentation process so basically your tests are running state-full, this might wreak havoc if your tests have some sort of dependency on the process state. In Android test orchestrator each test is run in its own process so dependencies aren't an issue.

如果一个测试崩溃,它将阻止其余测试套件运行

if one test crashes, it prevents the remainder of the test suite from running

这里的崩溃是进程的崩溃,而不是活动/应用程序的崩溃.您可以通过在其中插入一个测试来进行测试System.exit(0);通常,这将停止整个测试运行,而在Android测试协调器中,测试将按预期进行.

The crash in question here is a crash of the process, not the activity/application. You can test this by inserting in one your tests System.exit(0); Typically, this will stop the whole test run while in Android test orchestrator the tests continue as expected.

为了完整起见,Android Test Orchestrator在每次测试后均以pm clear运行.

For completeness, Android Test Orchestrator runs pm clear after each test.

这是对Google的监督,已从官方文档,如这里.

This is an oversight of google and has been retracted from the official documentation as can be observed here.

基本上,使用Android测试协调器的优点在于,每个测试都有独立的过程,从而提高了稳定性并确保测试的完全执行.

Basically, The advantages of using Android test orchestrator is all about the separate process for each test which improves stability and ensures full execution of tests.

这篇关于什么是Android Test Orchestrator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆