You are browsing the archive for stress testing.

Some Thoughts about Android apps Stressful Testing

October 9, 2016 in Android, Stress Testing

Mobile Apps Performance testing is one of the most important factors which can ensure that apps are really powerful and flexible enough to work on different set of devices. The importance of this topic appears clearly when there are a lot of vendors that produce many devices with many models and capabilities on the platform (which is the case for Android Platform). This article discusses important tips that should be followed for performing stressful Android app testing which are necessary before publishing apps to stores.

Android Monkey Tests

Monkey tests are special type of tests which test the app under certain stressful conditions such as touching screen so many times, they are very useful in detecting issues that does not follow happy path flow (most of the time).

Android monkey tests are really a powerful option for performing stressful testing for Android apps. It sends a pseudo-random stream of user events into the system, which acts as a stress test on the mobile app you are developing.

Using Monkey Tests

Using monkey tests is easy, you can launch the Monkey using a command line on your development machine or from a script. Because the Monkey runs in the emulator/device environment, you must launch it from a shell in that environment. You can do this by prefacing adb shell to each command, or by entering the shell and entering Monkey commands directly.

The following command runs Monkey tests in your app sending 500 pseudo-random events to it:
adb shell monkey -p your.package.name -v 500

More information about the command parameters can be found in:
https://developer.android.com/studio/test/monkey.html

Important Tips for having an efficient monkey test

1. Pin your App screen

Because a monkey test can send random events anywhere even outside the app. Your monkey tests can fail testing your app, so it is really recommended to pin app screen as follows (This procedure works for Android 5.0 Lollipop):
https://www.cnet.com/how-to/ho-to-pin-apps-in-android-5-lollipop/

2. Stress Complex Activities as much as you can

Sometimes, you may need to perform stress testing on specific activities of your app, this is very useful to identify problems as early as possible especially for complex activities.

In order to do this, you need to add the following intent-filter to your activity or activities:

<activity android:name="ComplexActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.MONKEY" />
    </intent-filter>
</activity>

Then from command line specify the category (-c) parameter as follows:

adb shell monkey -p your.package.name -c android.intent.category.LAUNCHER -c android.intent.category.MONKEY 5000 

This will run monkey tests on LAUNCHER and MONKEY activities.

3. Have different levels of stress tests until reaching your app limits

Generally, it is recommended to start your monkey tests with small number of events and then increase them a bit by bit until you reach the app limits.

Also it is recommended to use the --throttle (which represents a fixed delay between events) to slow down the monkey.

4. Integrate your monkey tests with your CI

Ideally, monkey tests have to run for many hours on CI night jobs in order to detect app problems under stress as much as possible.

Monkey tests scripts can be easily integrated with CI using Execute shell task.

5. Perform monkey tests on real devices as much as you can

At the end, performing monkey tests on real devices as well as emulators are needed to detect the maximum number of issues as early as possible.

Skip to toolbar