Monkey is a command line tool that runs over ADB shell command line. It generates N number of random events such as random touches, gesture, system level events, etc. and sends to the system or app which you want to test.
How Monkey works?
It’s very simple, all you need to do is open the terminal or command prompt and navigate to the platform-tool directory:You may find it android >
android > SDK > platform-tool
Note: Install ADB in the directory platform-tool if not already there.
Now run your app in device or emulator through developing machine, navigate to the screen of your app which you want to test, and then run following command in the Terminal:
$ adb shell monkey -p your.package.name -v 500
You can include the following events as per requirements:
-s <seed> : To execute same event each time, You have to use same seed value each time to generate same sequence of event.
--throttle <millisecond> : To slow down or insert delay in event execution.
--pct-touch<percent> : To Adjust percentage of touch event
Step 1: Open command prompt
Step 2: Move to Android SDK folder — platforms-tools — where adb command run
Step 3: Copy following command
adb -e shell monkey –ignore-crashes -p com.csform.android.uiapptemplate 500 > test_logs.txt
after successful done we can check logs in
Path To Android SDK /platforms-tools/test_logs.txt
Parameters:
-e // to run on emulator for device use -d
For this demo we are using Genymotion.com emulator
–ignore-crashes //If you specify this option, the Monkey will continue to send events to the system, until the specified count is completed.
com.csform.android.uiapptemplate //package name of your app
500 //number of events count
test_logs.txt //file name where you want to store your logs
http://en.dev.mi.com/doc/p=208/index.html
https://developer.android.com/studio/test/monkey.html
Mi Developer Document Center
Introduction of Monkey Test
adb shell monkey -v –throttle 300 –pct-touch 30 –pct-motion 20 –pct-nav 20 –pct-majornav 15 –pct-appswitch 5 –pct-anyevent 5 –pct-trackball 0 –pct-syskeys 0 -p ‘%s’ 1000