Monday, April 25, 2011

MonkeyRunner Automation Testing Tool for Android O.S

MonkeyRunner Automation Testing Tool for Android O.S: 
The monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code. With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation. The monkeyrunner tool is primarily designed to test applications and devices at the functional/framework level and for running unit test suites, but you are free to use it for other purposes.
The monkeyrunner tool is not related to the UI/Application Exerciser Monkey, also known as the monkey tool. The monkey tool runs in an adb shell directly on the device or emulator and generates pseudo-random streams of user and system events. In comparison, the monkeyrunner tool controls devices and emulators from a workstation by sending specific commands and events from an API.
The monkeyrunner tool provides these unique features for Android testing:
  • Multiple device control: The monkeyrunner API can apply one or more test suites across multiple devices or emulators. You can physically attach all the devices or start up all the emulators (or both) at once, connect to each one in turn programmatically, and then run one or more tests. You can also start up an emulator configuration programmatically, run one or more tests, and then shut down the emulator.
  • Functional testing: monkeyrunner can run an automated start-to-finish test of an Android application. You provide input values with keystrokes or touch events, and view the results as screenshots.
  • Regression testing - monkeyrunner can test application stability by running an application and comparing its output screenshots to a set of screenshots that are known to be correct.
  • Extensible automation - Since monkeyrunner is an API toolkit, you can develop an entire system of Python-based modules and programs for controlling Android devices. Besides using the monkeyrunner API itself, you can use the standard Python os and subprocess modules to call Android tools such as Android Debug Bridge.
    You can also add your own classes to the monkeyrunner API. This is described in more detail in the section Extending monkeyrunner with plugins.

    The monkeyrunner tool uses Jython, a implementation of Python that uses the Java programming language. Jython allows the monkeyrunner API to interact easily with the Android framework. With Jython you can use Python syntax to access the constants, classes, and methods of the API.
  • MonkeyRunner is an open-source tool used for automating functional tests for Android applications. It is a part of the Android SDK and is built on top of the Jython language. It provides a simple API for writing scripts to simulate user interaction with an Android device or emulator, such as tapping on buttons, entering text, and taking screenshots.

  • MonkeyRunner uses the Android Debug Bridge (ADB) to connect to the device or emulator, and the scripts are written in Python. The tool provides various functions to interact with the device, such as touching the screen, pressing buttons, taking screenshots, and more. The scripts can also be used to automate complex tasks, such as installing and uninstalling apps, rebooting the device, and capturing logs.

  • One of the advantages of using MonkeyRunner is that it allows for cross-platform testing, as it can be used to test applications on multiple devices and emulators. It also enables developers to run tests on a variety of Android versions and screen sizes.

  • However, MonkeyRunner has some limitations, such as the lack of support for testing gestures and animations, which are important features in many Android applications. Additionally, it can be challenging to debug scripts and troubleshoot errors, as the tool does not provide detailed error messages.

  • Overall, MonkeyRunner is a useful tool for automating functional tests for Android applications. It provides a simple API and allows for cross-platform testing, but it has some limitations and can be challenging to debug.