Andriod App之压力测试Monkey

Monkey是一个耳熟能详的工具,只要一提monkey很多人会说,我知道,能随机发送一些操作命令使其在手机上执行(发送伪随机用户事件的工具)

准备工作

1、android操作系统的手机

2、一台电脑,通过usb线将电脑和手机进行连接,并通过adb(Android debug bridge)操作手机里的Monkey命令

Adb安装以及可能遇到的一些问题,请参考“Android-USB-Monkey测试

官网参考连接

General--helpPrints a simple usage guide.

-vEach -v on the command line will increment the verbosity level. Level 0 (the default) provides little information beyond startup notification, test completion, and final results. Level 1 provides more details about the test as it runs, such as individual events being sent to your activities. Level 2 provides more detailed setup information such as activities selected or not selected for testing.

命令行的每一个 -v 将增加反馈信息的级别。 Level 0( 缺省值 ) 除启动提示、测试完成和最终结果之外,提供较少信息。 Level 1 提供较为详细的测试信息,如逐个发送到 Activity 的事件。 Level 2 提供更加详细的设置信息,如测试中被选中的或未被选中的 Activity 。 事件


Events-s Seed value for pseudo-random number generator. If you re-run the Monkey with the same seed value, it will generate the same sequence of events.

伪随机数生成器的 seed 值。如果用相同的 seed 值再次运行 Monkey ,它将生成相同的事件序列。


--throttle Inserts a fixed delay between events. You can use this option to slow down the Monkey. If not specified, there is no delay and the events are generated as rapidly as possible.

在事件之间插入固定延迟。通过这个选项可以减缓 Monkey 的执行速度。如果不指定该选项, Monkey 将不会被延迟,事件将尽可能快地被产成。


--pct-touch Adjust percentage of touch events. (Touch events are a down-up event in a single place on the screen.)

调整触摸事件的百分比 ( 触摸事件是一个 down-up 事件,它发生在屏幕上的某单一位置 ) 。


--pct-motion Adjust percentage of motion events. (Motion events consist of a down event somewhere on the screen, a series of pseudo-random movements, and an up event.)

调整动作事件的百分比 ( 动作事件由屏幕上某处的一个 down 事件、一系列 的伪随机事件和一个 up 事件组成 ) 。


--pct-trackball Adjust percentage of trackball events. (Trackball events consist of one or more random movements, sometimes followed by a click.)

调整轨迹事件的百分比 ( 轨迹事件由一个或几个随机的移动组成,有时还伴随有点击 ) 。


--pct-nav Adjust percentage of "basic" navigation events. (Navigation events consist of up/down/left/right, as input from a directional input device.)

调整“基本”导航事件的百分比 ( 导航事件由来自方向输入设备的 up/down/left/right 组成 ) 。


--pct-majornav Adjust percentage of "major" navigation events. (These are navigation events that will typically cause actions within your UI, such as the center button in a 5-way pad, the back key, or the menu key.)

调整“主要”导航事件的百分比 ( 这些导航事件通常引发图形界面中的动作,如: 5-way 键盘的中间按键、回退按键、菜单按键 )


--pct-syskeys Adjust percentage of "system" key events. (These are keys that are generally reserved for use by the system, such as Home, Back, Start Call, End Call, or Volume controls.)

调整“系统”按键事件的百分比 ( 这些按键通常被保留,由系统使用,如 Home 、 Back 、 Start Call 、 End Call 及音量控制键 ) 。


--pct-appswitch Adjust percentage of activity launches. At random intervals, the Monkey will issue a startActivity() call, as a way of maximizing coverage of all activities within your package.

调整启动 Activity 的百分比。在随机间隔里, Monkey 将执行一个 startActivity () 调用,作为最大程度覆盖包中全部 Activity 的一种方法。


--pct-anyevent Adjust percentage of other types of events. This is a catch-all for all other types of events such as keypresses, other less-used buttons on the device, and so forth.

调整其它类型事件的百分比。它包罗了所有其它类型的事件,如:按键、其它不常用的设备按钮、等等。 约束限制


Constraints-p If you specify one or more packages this way, the Monkey willonlyallow the system to visit activities within those packages. If your application requires access to activities in other packages (e.g. to select a contact) you'll need to specify those packages as well. If you don't specify any packages, the Monkey will allow the system to launch activities in all packages. To specify multiple packages, use the -p option multiple times — one -p option per package.

如果用此参数指定了一个或几个包, Monkey 将只允许系统启动这些包里的 Activity 。如果你的应用程序还需要访问其它包里的 Activity( 如选择取一个联系人 ) ,那些包也需要在此同时指定。如果不指定任何包, Monkey 将允许系统启动全部包里的 Activity 。要指定多个包,需要使用多个 -p 选项,每个 -p 选项只能用于一个包。


-c If you specify one or more categories this way, the Monkey willonlyallow the system to visit activities that are listed with one of the specified categories. If you don't specify any categories, the Monkey will select activities listed with the category Intent.CATEGORY_LAUNCHER or Intent.CATEGORY_MONKEY. To specify multiple categories, use the -c option multiple times — one -c option per category.

如果用此参数指定了一个或几个类别, Monkey 将只允许系统启动被这些类别中的某个类别列出的 Activity 。如果不指定任何类别, Monkey 将选择下列类别中列出的 Activity : Intent.CATEGORY_LAUNCHER 或 Intent.CATEGORY_MONKEY 。要指定多个类别,需要使用多个 -c 选项,每个 -c 选项只能用于一个类别。


Debugging--dbg-no-eventsWhen specified, the Monkey will perform the initial launch into a test activity, but will not generate any further events. For best results, combine with -v, one or more package constraints, and a non-zero throttle to keep the Monkey running for 30 seconds or more. This provides an environment in which you can monitor package transitions invoked by your application.

设置此选项, Monkey 将执行初始启动,进入到一个测试 Activity ,然后不会再进一步生成事件。为了得到最佳结果,把它与 -v 、一个或几个包约束、以及一个保持 Monkey 运行 30 秒或更长时间的非零值联合起来,从而提供一个环境,可以监视应用程序所调用的包之间的转换。


--hprofIf set, this option will generate profiling reports immediately before and after the Monkey event sequence. This will generate large (~5Mb) files in data/misc, so use with care. SeeTraceviewfor more information on trace files.

设置此选项,将在 Monkey 事件序列之前和之后立即生成 profiling 报告。这将会在 data/misc 中生成大文件 (~5Mb) ,所以要小心使用它。

--ignore-crashesNormally, the Monkey will stop when the application crashes or experiences any type of unhandled exception. If you specify this option, the Monkey will continue to send events to the system, until the count is completed.

通常,当应用程序崩溃或发生任何失控异常时, Monkey 将停止运行。如果设置此选项, Monkey 将继续向系统发送事件,直到计数完成。


--ignore-timeoutsNormally, the Monkey will stop when the application experiences any type of timeout error such as a "Application Not Responding" dialog. If you specify this option, the Monkey will continue to send events to the system, until the count is completed.

通常,当应用程序发生任何超时错误 ( 如“ Application Not Responding ”对话框 ) 时, Monkey 将停止运行。如果设置此选项, Monkey 将继续向系统发送事件,直到计数完成。


--ignore-security-exceptionsNormally, the Monkey will stop when the application experiences any type of permissions error, for example if it attempts to launch an activity that requires certain permissions. If you specify this option, the Monkey will continue to send events to the system, until the count is completed.

通常,当应用程序发生许可错误 ( 如启动一个需要某些许可的 Activity) 时, Monkey 将停止运行。如果设置了此选项, Monkey 将继续向系统发送事件,直到计数完成。


--kill-process-after-errorNormally, when the Monkey stops due to an error, the application that failed will be left running. When this option is set, it will signal the system to stop the process in which the error occurred. Note, under a normal (successful) completion, the launched process(es) are not stopped, and the device is simply left in the last state after the final event.

通常,当 Monkey 由于一个错误而停止时,出错的应用程序将继续处于运行状态。当设置了此选项时,将会通知系统停止发生错误的进程。注意,正常的 ( 成功的 ) 结束,并没有停止启动的进程,设备只是在结束事件之后,简单地保持在最后的状态。


--monitor-native-crashesWatches for and reports crashes occurring in the Android system native code. If --kill-process-after-error is set, the system will stop.

监视并报告 Android 系统中本地代码的崩溃事件。如果设置了 –kill-process-after-error ,系统将停止运行。


--wait-dbgStops the Monkey from executing until a debugger is attached to it.

停止执行中的 Monkey ,直到有调试器和它相连接。

PS:Monkey可以进行一些随机操作,但是估计操作可以借助MonkeyScript来完成

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,569评论 4 363
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,499评论 1 294
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,271评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,087评论 0 209
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,474评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,670评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,911评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,636评论 0 202
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,397评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,607评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,093评论 1 261
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,418评论 2 254
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,074评论 3 237
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,092评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,865评论 0 196
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,726评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,627评论 2 270

推荐阅读更多精彩内容