Exerciser monkey tool can be used to generate pseudo-random streams of user events such as clicks, touches, gestures and system-level events. This can be used to stress test an app on android mobile phone or emulator. For the purpose of this article, I’ll use chrome app on android phone connected to Macbook.
Here are the quick steps to run exerciser monkey tool.
Ensure phone is recognized by adb
Assuming you have enabled USB debugging in your mobile and android sdk installed on your Mac (or other machine), run the following command to ensure that your device is recognized.
$adb devices List of devices attached [SOMEID] device
You should see your device id as outcome if your device us detected.
Run monkey tool for chrome
Run monkey tool for chrome with 100 random events
$ adb shell monkey -p com.android.chrome -v 100
In case there are multiple devices use -s deviceid
$ adb -s [DEVIDE_ID] shell monkey -p com.android.chrome -v 100
To add throttle to evens use –throttle [milliseconds]
$ adb shell monkey -p com.android.chrome -v --throttle 10000 10
To provide a seed to pseudo-random number generator use -s [seed]. This will make it re-runnable with same sequence of events for same seed.
$ adb shell monkey -p com.android.chrome -v -s 101 --throttle 1000 100
To control percentage of specific events e.g. touch events use –pct-touch
$ adb shell monkey -p com.android.chrome -v -s 101 --pct-touch 50 --throttle 1000 100