monkey初级

搭建环境问题
1. adb shell提示  error: unknown host service
  1. 打开命令行,输入命令:netstat -ano | findstr "5037"
  2. 打开任务管理器,在菜单中的查看->选择列中将PID勾选上,然后点击PID列的表头,让其递增排序便于根据pid找到进程名称
  3. 杀掉该进程即可

2. adb shell -> cd data/data(查找该机器中都有哪些apk.  cd过程中提示 permission denied
    机器需要root权限才可以.

运行方式:
1. adb shell
2. cd system/bin
3. monkey <event-count>
    <event-count>是一个随机数事件,针对data下的所有apk执行随机

基本指令:
[adb shell] monkey [options] <eventcount>
option操作都是根据具体的需求设定的,主要分为常规类、事件类、约束类和调试类4种

==========常规类==========

monkey -h  ->打开帮助
monkey -v   ->打印日志, -v越多日志越详细(monkey -v -v -v)最多支持3个
 
事件类:事件类命令可以对随机事件进行调控,从而使其遵照设定运行。
1. adb shell monkey -f <scriptfile> <event-count>
    e.g. monkey -f /mnt/scda/test 1 (/mnt/scda/test为monkey脚本路径/1 为循环次数)
2. adb shell monkey -s  <seed> <event-count>
    -s:后面接随机数程承旗的seed值,如果seed相同,则两次Monkey测试所产生的事件序列也相同的。
   e.g. adb shell monkey -s  10 100
3. adb shell monkey -p <package> <event-count>
    -p:指定包,可使用多次  
   e.g. adb shell monkey -p cn.emoney.acg -p com.acsm.harvest 10
4. adb shell monkey --throttle <milliseconds>
    --throttle:后面接时间,单位为ms,标示固定延迟
   e.g. adb shell monkey --throttle 1000
========百分比概念=======
monkey运行时会模拟各种操作如点击,并分配一定的操作所占百分比。总共为100%,如图

5. adb shell monkey --ptc-touch <precent>
    --ptc-touch:后面接触摸事件百分比,每一个press down-up 事件
6. adb shell monkey --ptc-motion <percent>
    --ptc-motion:后面接动作事件百分比,(动作事件不单单是指手势操作,它泛指从某一位置按下,即down事件;后经过一系列伪随机事件后弹起,即up事件)
7. adb shell monkey --ptc-trackball <percent>
    --ptc-trackball:后面接轨迹球时间百分比,后面接轨迹球事件百分比(轨迹球事件包括一系列的随机移动,以及偶尔随在移动后面的点击事件)
8. adb shell monkey --pct-nav <percent>
--ptc-nav:后面接基本导航时间百分比,基本导航事件指来自输入设备的上下左右事件
9. adb shell monkey --pct-majornav <percent>
--ptc-majornav:后面接主要导航事件的百分比
10. adb shell monkey --pct-syskeys <precent>
--ptc-syskeys: 后面接系统按键事件百分比
系统按键事件百分比指的是 HOME/BACK/拨号键/挂断键及音量键等
11. adb shell monkey --pct-appswitch <precent>
--ptc-appswitch: 后面接应用启动事件百分比
即打开应用,听过调用startActivity()方法最大限度地开启该package下的所有应用
12. adb shell monkey --pct-anyevent <percent>
--ptc-anyevent: 后面接其他类型事件百分比,除了上述以外的所有事件


==========约束类=========

1. adb shell monkey -p <packageName> <eventcount>
限制包,可以使用多个-p
2. adb shell monkey -c <main-category > <eventcount>
-c后面接一个或多个类别名,monkey将只允许系统启动这些类别中某个类别列出的activity
main-category:如果不指定任何类别的activity,Monkey将选择 Intent.CATEGORY_LAUNCHER (加载主页面)Intent.CATEGORY_MONKEY中的activity

==========调试类=========

1. adb shell monkey --dbg-no-events <event-count>
--dbg-no-events:设置此项后,monkey将进行初始启动,进入到某个测试activity中不会进一步生成事件.该项一般会与-v -p 和--throttle等联合使用,从而提供一个可见是应用程序所调用包之间的转换
2. adb shell monkey --hprof <event-count>
--hprof:事件序列前后立即生成 profilfing report.
即分析报告,在data/misc中生成大概5MB左右文件
3. adb shell monkey --ignore-crash <event-count>
--ignore-crash:忽略崩溃,monkey将继续运行直到计数完成
4. adb shell monkey --ignore-timeouts <event-count>
--ignore-timeouts:发生任何超时错误时,monkey将继续运行直到计数完成
5. adb shell monkey --ignore-security-exceptions <event-count>
--ignore-security-exceptions:发生任何权限错误(如启动一个需要某些权限的Activity),monkey将继续寻星直到计数完成
6. adb shell monkey --kill-process-after-error <event-count>
--kill-process-after-error:monkey在应用程序出错后通知系统停止发生错误的进程
7. adb shell monkey --monitor-native-crashes <event-count>
--monitor-native-crashes: monkey运行时native code的崩溃事件将被监视并报告
8. adb shell monkey --wait-dbg <event-count>
--wait-dbg:暂停执行中的monkey.直到调试器与他链接







  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值