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

不羁的心 提交于 2019-12-12 01:29:16

问题


How to use MonkeyRunner and Robotium together (not separately!) for testing my Android app


回答1:


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?




回答2:


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.



来源:https://stackoverflow.com/questions/24955187/how-to-use-monkeyrunner-and-robotium-together-not-separately

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!