The Importance of Stress Testing in Android
By: Kayvan Kaseb
Tags: Android Development, Stress Testing, Monkey, Android, Android Testing

Android Application Testing

Basically, testing is the process of executing a software with the purpose of finding errors. As we know, the process of testing Android applications have always been a controversial issue due to some limitations in developing Android apps in comparison with other types of software. Actually, if you see an Android app that is worked without crash, you should appreciate those developers behind the project because testing an Android app could be a tricky task even for experts. This essay will discuss the importance of Stress Testing in developing Android applications, and it recommends the Monkey tool for performing this task as well.

Challenges and problems in testing Android applications

There are a number of devices in the market with various versions of Android OS. It is not reasonable to get a new device every time, and also simulators are not dependent. Nowadays, time to market is a significant matter. So, release cycles have become short and rapid period of time. A new Android version is usually released every 10 or 12 months. There is a vast diversity of android based in terms of screen size, hardware capabilities, and the Internet bandwidth . Emulators or simulators fail to show the real results.

What is the meaning of Stress Testing?

Stress Testing is a kind of non-functional testing, which verifies the stability and reliability of the system. This test mainly measures the system on its robustness and error handling capabilities under extremely heavy load situations. It means stress testing is done to make sure that the system would not crash under critical conditions.

Stress testing is extremely vital for the following reasons as well:

To check whether the system works under unusual conditions.

Displaying appropriate error message when the system is under pressure and stress.

System failure under extreme conditions could be helpful for predicting the real cases in future

Using Monkey in Android application testing

What is Monkey?

The UI/Application Exerciser Monkey, usually called “monkey”, is a command-line tool, which sends pseudo-random streams of keystrokes, touches, and gestures to a device. You run it with the Android Debug Bridge (adb) tool.

In fact, you can use it for stress testing your application and report back errors that are faced. Besides, you can be able to repeat a stream of events by running the tool each time with the same random number.

Benefits of using Monkey

You can restrict it to any specific package. If your app crashes or has any sort of exception, it will stop and report the error quickly. It helps catch frequent exceptions such as NullPointerException and ANR faster and easier.

How to use Monkey

Open a command prompt and just navigate to this directory with command as below:

android ->sdk ->platform-tools

2. Attach your device with the computer, and run the following command:

$ adb shell monkey -p <app_package> -v <event_count>

For instance:

$ adb shell monkey -p your.package.name -v 500

shell is just an interface on the device that translates our commands to system commands.

v is mentioned for verbose method.

500 is the frequency count or the number of events to be sent for testing.

Difference between Monkey and Monkeyrunner

The Monkey runs directly onto the device or emulator and creates streams of simulated user and system events. The Monkeyrunner tool, in contrast, is an application programming interface (API) that allows you to write a program to control the devices and emulators. In other words, Monkeyrunner is a automated tool for different testing purposes (is not only used for UI) and also is complicated than Monkey in using ;whereas, Monkey is a quick tool for stress testing with simple instructions. Therefore, these tools are completely different.

In conclusion, testing is an essential part of developing an Android application particularly Stress Testing. Stress testing’s objective is to check the application under extreme situations. Thus, we cannot neglect this method if want to have a stable and reliable application.