Monkey学习
一个App的压测实践
- 手机开发者选项,勾选USB调试
- 手机连接电脑,使用软连接
adb deices查询设备 - 安装测试:
adb install + 包名/路径 - 发送压测指令:
adb shell monkey <num><告诉Monkey帮助我们完成指令包括截屏等> - 获取apk包名:
adb logcat | grep START - 给指定包打压力:
adb shell monkey -p packagename 1000
Monkey 高级参数的应用
- throttle参数:指定事件之间的间隔
adb shell monkey --throttle <milliseconds> - seed参数:指定随机生成数的seed值
adb shel monkey -s<seed> <event-count> - 触摸事件:指定触摸事件的百分比
adb shell monkey --pct-touch <percent> - 动作事件:指定动作事件的百分比
adb shell monkey --pct-motion <percent> - 轨迹球事件:设定轨迹球事件的百分比
adb shell monkey --pct-trackball <percent> - 基本导航事件:设定基本导航事件百分比,输入设备的上、下、左、右
adb shel monkey --pct-nav <percent> - 主要导航事件:设置主要导航事件百分比,兼容中间、返回键、菜单键
adb shell monkey --pct-majornav <percent> - 系统导航事件:设定系统导航事件百分比,HOME、BACK、拨号及音量
adb shell monkey --pct-syskeys <percent> - 启动Activity事件:设置启动Activity事件百分比
adb shell monkey --pct-appswitch <percent> - 不常用事件:设定不常用事件百分比
adb shell monkey --pct-anyevent <percent> - 崩溃事件:忽略崩溃和异常
adb shell monkey --ignore-crashes <event-count> - 超时事件:
adb shell monkey --ignore-timeouts <event-count><如果在app运行时出现ANR,可在手机/data/anr/traces.txt查看>
Monkey Script
执行Monkey脚本的命令
adb shell monkey -f <scriptfile> <event-count>注意:如果需要学习如何编写Monkey Script 需要先熟悉以下几个命令。
DisPatchTrackball命令:轨迹球事件
本文介绍如何利用Monkey工具进行App的压力测试。从手机开发者选项配置到ADB命令应用,再到Monkey高级参数详解,包括throttle、seed等,最后还介绍了MonkeyScript的编写方法。
107

被折叠的 条评论
为什么被折叠?



