伪随机(pseudo-random)
的用户事件流(如按键输入、触摸屏输入、手势输入等),可以对待测的目标利用或全部Android系统进行压力测试。因此Monkey测试是1种为了测试软件的稳定性、硬朗性的快速有效的方法基本语法:
$ adb shell monkey [options] <event-count>
如果不指定options
,即类似于使用命令adb shell monkey 1000
,那末将会对全部系统中安装的package发送事件流,换种说法就是对全部Android系统进行Monkey压力测试
下面是1个对指定利用(Android自带的系统设置
利用)进行Monkey测试的例子,发送的事件流数目为1000:
adb shell -p com.android.settings 1000
获得选项列表,Android 4.4版本中输入adb shell monkey
,会显示选项列表以下:
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