Android 测试:UIAutomator 与 Espresso [英] Android Testing: UIAutomator vs Espresso
问题描述
我正在寻找用于 Android UI 自动化的测试框架,但偶然发现了 UI Automator
和 Espresso
,这是我感到困惑的部分 -
I was seeking for test frameworks for Android UI automation and I stumbled upon UI Automator
and Espresso
and this is the part I am confused about -
- 两者均由 Google 维护
- 两者都用于功能 UI 测试
- 两者都是
Android
唯一的框架
- Both are maintained by Google
- Both are used for functional UI testing
- Both are
Android
only frameworks
所以我的问题/疑问是 -
So my questions/doubts here are -
UI Automator
和Espresso
的主要区别是什么?- 是否需要修改源代码以集成任何这些框架?
- 一个框架比另一个有什么优势吗?如果是,那么哪个框架最适合 Android 应用程序的 UI 自动化?
- What is the major difference between
UI Automator
andEspresso
? - Will the source code have to be modified to integrate any of these frameworks?
- Does one framework hold any advantage over the other? If yes, then which framework is the most suitable for UI automation of an Android app?
推荐答案
其实不需要选择.UIAutomator 和 Espresso 使用相同的检测运行器,因此您可以在单个测试中使用来自它们的命令.Espresso 在 UI 上具有各种匹配器、断言和操作,而自动化工具则没有:
Actually, you don't need to choose. UIAutomator and Espresso use the same instrumentation runner, so you can use commands from both of them in a single test. Espresso has variety of matchers, assertions and actions on UI, that automator doesn't have:
Espresso 在单独的线程中运行,与其他测试框架相比,它的速度非常快.
Espresso is running in separate thread and it is really fast comparing to other test frameworks.
作为摘要:在您的测试中同时使用它们,Espresso 是主要的,而 UIAutomator 作为 OS 集成的附加工具.
as Summary: use both of them in your tests, Espresso is main and UIAutomator as an additional tool for OS integration.
这篇关于Android 测试:UIAutomator 与 Espresso的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!