简体   繁体   English

如何一起使用MonkeyRunner和Robotium(不是分开使用!)

[英]How to use MonkeyRunner and Robotium together (not separately!)

如何一起使用MonkeyRunner和Robotium(不是单独使用!)来测试我的Android应用

Well, I found this 好吧,我发现了这个

http://download.yandex.ru/company/experience/yac2012/kharitonenko_yac_2012.pdf http://download.yandex.ru/company/experience/yac2012/kharitonenko_yac_2012.pdf

slide #22. 幻灯片22。 There is a scheme, how to use a combination of Robotium and Monkeyrunner. 有一个方案,如何结合使用Robotium和Monkeyrunner。 For example, when in your tests, you need to take a snapshot from Android native Camera, and Robotium can't do that. 例如,在测试中,您需要从Android本机Camera拍摄快照,而Robotium无法做到这一点。 Monkeyrunner can do it. Monkeyrunner可以做到。 But most of your test case developed in Robotium, so as I understood, you can run monkeyrunner script for this action, and then continue with Robotium. 但是,您的大部分测试用例都是在Robotium中开发的,据我所知,您可以为该操作运行monkeyrunner脚本,然后继续使用Robotium。 Am I right? 我对吗?

In general MonkeyRunner is based on a generic build-in android instrumentation, based on user inputs. 通常,MonkeyRunner基于通用的内置android工具,并基于用户输入。 It does not require any code knowledge and does not yield any access to the application process. 它不需要任何代码知识,也不会对应用程序进程产生任何访问。

Whereas Robotium or Espresso is based on the GoogleInstrumentationTestRunner, which runs within the same process like your app, hence allows direct access to view components but does also require code access. Robotium或Espresso基于GoogleInstrumentationTestRunner,它在与您的应用相同的过程中运行,因此可以直接访问视图组件,但也需要代码访问权限。

So in general you could do most of the monkey-runner input actions with Robotium / Espresso, but what you can't is to use monkey-runner from within a Robotium test, this is prevented by Androids security mechanisms. 因此,一般来说,您可以使用Robotium / Espresso执行大多数猴子运行程序输入操作,但是您不能在Robotium测试中使用猴子运行程序,这是Android的安全机制所阻止的。

Another approach would be running monkey-runner instrumentation's along with Robotium tests in a scripted environment, where monkey-runner is switching between processes, and at a certain time executing the needed Robotium test, but this kind of concept could be very unstable. 另一种方法是在脚本环境中运行Monkey-runner仪器以及Robotium测试,在该环境中Monkey-runner在进程之间进行切换,并在一定时间执行所需的Robotium测试,但是这种概念可能非常不稳定。

An alternative to both are UI Automator Tests . 两者的替代方法是UI Automator Tests They provide the benefits of Robotium - Access to the View Hierarchy - and the flexibility of Monkey Runner - using arbitrary input commands -, but does not require any code knowledge. 它们提供了Robotium的优点-访问视图层次结构-以及Monkey Runner的灵活性-使用任意输入命令-,但不需要任何代码知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM