简体   繁体   中英

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

slide #22. There is a scheme, how to use a combination of Robotium and Monkeyrunner. For example, when in your tests, you need to take a snapshot from Android native Camera, and Robotium can't do that. Monkeyrunner can do it. 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. Am I right?

In general MonkeyRunner is based on a generic build-in android instrumentation, based on user inputs. 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.

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.

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.

An alternative to both are 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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