The Monkey ToolGoofing around with Android
A UI/Application Exerciser
● The Monkey is a command-line tool that that you can run on any Android emulator instance or on a device.
● It sends a pseudo-random stream of user events into the system, which acts as a stress test on the application software you are developing.
History and Availability
● The Monkey is a built-in Android UI testing tool, and can be accessed through use of the adb (android debugging bridge) supplied to android developers for free by Google.
Other UI/App Testing Tools
● There aren’t any other popular Android UI automated testing tools -- the Monkey tool is meant to be used as a stress-test, while other tools use specific test cases.
● Although ‘monkeyrunner’ is similar to the monkey tool in some ways, Google states that they are unrelated.
Sustainability and Performance
● Since the Monkey is included as part of the Android SDK, it is kept up-to-date by Google and has excellent reliability.
● However, testing on an external device, rather than a virtual one, leads to much faster results and less headache. Running the tool on a virtual device can take a lot of processing power.
Benefit / Cost
● The tool is packaged with the Android SDK, so it is free to use. This also means that it is compatible with any existing Android project.
● In order to use the monkey, just navigate to the android-sdk folder in your shell, and run the monkey tool on any connected device. Anyone with the sdk can do this.
Running the Tool
● The monkey has no GUI interface
● So it must be run from a shell.
Running the Tool
● In order to run the monkey, you must have an android device (virtual or otherwise) connected to adb.
● You can only have one device running at a time.
Running the Tool
● After starting up, the monkey begins sending user interface events to the device; this is viewable in real time.
Running the Tool
● Since the tool is random (pseudo-random), and you can control the amount of tests, the app can end up in odd situations.
Testing On Your Own
● In order to use the monkey tool, navigate to your android-sdk folder, and from there to platform-tools.
● From here, you can run the adb tool. ADB comes with a ‘shell’ option, which allows you to access the android device directly.
Testing On Your Own
● However, you can simply execute the tool through the adb shell, without actually going through the device files.
○ The ‘-p’ option allows you to choose a specific package for the tool to browse.
○ The ‘-v’ option is for setting something called ‘verbosity’ every -v added increases level of detail
○ The number (1000) at the end of the command is the number of actions to perform.
Thoughts
● The Monkey tool is fairly simple to use, and is a great for apps that have a significant amount of user input involved.
● For many apps, which only receive user input for buttons, or small text boxes, then the uses for this tool are limited.
● But if your app requires constant input (like drawing apps), or simultaneous inputs (like a game), then it could be very beneficial.