While monkey testing my app
% adb shell monkey -p com.foo.bar --throttle 1000 -v 14400
I notice that it accesses various system settings on my device like audio control and taking screen shots. According to http://developer.android.com/tools/help/monkey.html, this is the way it was meant to behave.
The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events.
Is it possible to exclude the system level events so the monkey completely focuses on my target app?
I looked at the '-c' option for constraints, but looking at the available Intents at http://developer.android.com/reference/android/content/Intent.html, I don't seem to see anything related to disabling such system level events.
Any pointers?
By setting the -pct-sysevents
to zero.
However, while using the monkey command, there is a small catch, which is regarding the order of events.
-v
is a verbosity flag.
COUNT must appear at the very end in the command
adb shell monkey -p your.package.name -v --pct-syskeys 0 9999
adb shell monkey -p your.package.name -v --pct-syskeys 0 COUNT
The command usage is given below.
usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]
[-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]
[--ignore-crashes] [--ignore-timeouts]
[--ignore-security-exceptions]
[--monitor-native-crashes] [--ignore-native-crashes]
[--kill-process-after-error] [--hprof]
[--pct-touch PERCENT] [--pct-motion PERCENT]
[--pct-trackball PERCENT] [--pct-syskeys PERCENT]
[--pct-nav PERCENT] [--pct-majornav PERCENT]
[--pct-appswitch PERCENT] [--pct-flip PERCENT]
[--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]
[--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]
[--pkg-whitelist-file PACKAGE_WHITELIST_FILE]
[--wait-dbg] [--dbg-no-events]
[--setup scriptfile] [-f scriptfile [-f scriptfile] ...]
[--port port]
[-s SEED] [-v [-v] ...]
[--throttle MILLISEC] [--randomize-throttle]
[--profile-wait MILLISEC]
[--device-sleep-time MILLISEC]
[--randomize-script]
[--script-log]
[--bugreport]
[--periodic-bugreport]
COUNT
All options are explained: https://developer.android.com/studio/test/monkey.html
I've managed to change the "system" events ratio by setting the --pct-syskeys
a much higher value.
In my case, the monkey keep showing the notification area and changing wifi settings (my app is wifi-only) and this parameter solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With