Monkey简介及命令

Monkey简介

Monkey是一个程序,运行在您的模拟器或设备上,并生成伪随机的用户事件流,如点击,触摸或手势,以及一些系统级事件。 可以使用Monkey以随机但可重复的方式对您正在开发的应用程序进行压力测试。

Monkey启动步骤

1. 连接移动设备

2. 连接成功后输入命令:adb shell

3. 进入到指定目录:cd /system/bin

4.输入 monkey命令看到如下提示则说明启动成功。

 
 

Monkey命令

Monkey运行命令格式:adb shell monkey [options] <event-count>

[options]是指monkey可传入的参数,是可选项(如果不指定options,Monkey将以无反馈模式启动,并把事件任意发送到安装在目标环境中的全部包)

<event-count> 是指随机发送事件数。如:输入100就是执行100个伪随机事件,为必选项。

一、常规命令:

adb shell monkey -v 1000-v:打印出日志信息,每个-v将增加反馈信息的级别。

-v越多日志信息越详细,不过目前最多支持3个-v

-v:0级,除启动提示,测试完成,最终结果外提供较少信息

-v -v:1级,提供较详细日志信息,如逐个发送到activity事件

-v -v -v:2级,提供更详细安装信息,如测试中被选中或者位被选中的activity事件

1000: 随机事件数

adb shell monkey -h    Monkey 参数帮助信息

 

二、事件类命令

adb shell monkey -f    测试脚本名运行

adb shell monkey -s    随机运行

adb shell monkey --throttle    指令间固定时间间隔

 

事件类命令--事件百分比:

adb shell monkey --ptc-touch      触摸事件百分百

adb shell monkey --ptc-motion    动作事件百分百

adb shell monkey --ptc-trackball    轨迹球事件百分百

adb shell monkey --ptc-nav    基本导航事件百分百

adb shell monkey --ptc-majornav    主要导航事件百分百

adb shell monkey --ptc-syskeys    系统按键事件百分百

adb shell monkey --ptc-appswitch    应用启动事件百分百

adb shell monkey --ptc-anyevent    Keypress不常用button

 

三、调试类命令

adb shell monke --dbg-no-events  监视应用程序

adb shell monkey --hprof  在实事件序列前后立即生成profiling report

 

调试类命令--出错后继续发送事件

adb shell monke --ignore-crashes        在应用程序崩溃后继续发送事件

adb shell monke --ignore-timeouts        在任何超时错误发生后继续发送事件

adb shell monke --ignore-security-exception    在应用程序权限错误发生后继续发送事件

 

调试类命令

adb shell monke --kill-process-after-error      在程序出错后通知系统停止发生错误的进程

adb shell monke --monitor-native-crashes      监视并报告monkey运行时Android系统native code的崩溃事件

adb shell monke --wait-dbg      暂停执行中的monkey,直到有调试器与它连接

例如:

posted @ 2020-05-28 14:25  Dear小七  阅读(305)  评论(0)    收藏  举报