By Prasenjit Bala on Nov 26, 2015, 5:26:50 AM
There are many automation tools out there in the market for testing android mobile applications. The one which comes along with Android SDK is called the Monkey Runner.
What is MonkeyRunner?
It is a tool which provides APIs/functions for writing programs for controlling an android device or emulator. It uses Jython, an implementation of Python that uses Java programming language.
It is primarily designed to test android mobile applications on emulator and devices to perform functional and regression testing.
Why Monkey name?
It is widely believed that if we allow six monkeys to pound on six typewriters at random, for a million years, they will recreate all the works of Isaac Asimov, a well-known author in America!!!
Also there is an adage like 'a thousand monkeys at a thousand typewriters will eventually type out the entire works of Shakespeare' J
What you can do with MonkeyRunner
You can write python scripts to test the applications on one or more connected devices and/or emulators. You can do the following things with monkey runner
- Install an application or test package
- Run an application
- Invoke an activity
- Send keystrokes or touch events to it
- Wake the screen/device
- Take screen shots of the user interface
- Store screen shots on your workstation
- Compare two screen shots taken using the tool
While writing python script for monkey runner, programmers find it very difficult to get the accurate touch points of controls on screen to send touch events. For this purpose, Android SDK provides another tool called 'Hierarchy Viewer'. This tool provides coordinates of any point on the device screen.
Significant disadvantage of this MonkeyRunner mobile application testing tool is that it is necessary to write scripts for each device. Another problem is that the tests require adjustments each time when user interface of the tested program is changed.
Also, Monkey runner cannot read text from the device though there is an extension of which is available. It is called EasyMonkeyDevice which is not officially documented by google.
In addition to that Monkey runner APIs can be extended to write user specific logic for their requirements.
- Eclipse IDE
- Android SDK
- Android Debug Bridge
- Android Package (APK) for the application to be tested
- Android device connected through USB (or emulator)
- Android drivers for specific device installed on computer
On an ending note, if we are interested in automating the testing process which involves only the basic level testing and need a cost effective automation tool, definitely Monkey runner can be considered.