一、简单介绍一下Monkey
Monkey工具直接运行在设备或模拟器的adb shell中,生成用户或系统的伪随机事件流
二、Monkey命令
1、adb shell monkey -p package 事件数(50)
# 随机完成50个事件
adb shell monkey -p com.xxx.xxx 50
2、throttle参数---指定事件之间的间隔
adb shell monkey --throttle 间隔毫秒数
随机完成50个事件,时间间隔1s
adb shell monkey -p com.xxx.xxx --throttle 1000 50
3、seed参数 ---指定随机生成数seed值(-s就是seed)
adb shell monkey -s<seed> 100(seed值)
随机完成50个事件,seed值100(只要seed值相同,最终执行顺序是一样的)
adb shell monkey -p com.xxx.xxx -s 100 50
4、触摸事件---设定点击事件百分比
adb shell monkey -p com.xxx.xxx --pct-touch<percent>
随机完成50个事件,点击事件100%,
adb shell monkey -p com.xxx.xxx --pct-touch 100 50
-v会把完成的所有事件的详情列出来,-v表示输出日志的级别,有-v、-v-v、-v-v-v三个级别,v越多,日志越详细
adb shell monkey -v -p com.xxx.xxx --pct-touch 100 50
5、动作事件---设定动作事件百分比
adb shell monkey -p com.xxx.xxx --pct-motion<percent>
6、轨迹球事件---设定轨迹球事件百分比
adb shell monkey -p com.xxx.xxx --pct-trackball<percent>
7、基本导航事件---设定基本导航事件百分比,输入设备的上下左右
adb shell monkey -p com.xxx.xxx --pct-nav<percent>
8、主要导航事件---兼容中间键、返回键、菜单按键
adb shell monkey -p com.xxx.xxx --pct-majornav<percent>
9、系统导航事件---HOME、音量、BACK、拨号键
adb shell monkey -p com.xxx.xxx --pct-syskeys<percent>
10、切换Activity事件
adb shell monkey -p com.xxx.xxx --pct-appswitch<percent>
11、不常用事件
adb shell monkey -p com.xxx.xxx --pct-anyevent<percent>
12、崩溃事件---忽略崩溃和异常
adb shell monkey -p com.xxx.xxx --ignore-carshes<event-count>
13、超时事件--忽略超时事件
adb shell monkey -p com.xxx.xxx --ignore-timeouts<event-count>