zoukankan      html  css  js  c++  java
  • Monkey官方帮助翻译&介绍

    都说想学好就看原文,英文不好为了翻译这个可费了大劲了。表格从GOOGLE官网复制到WORD里编辑,结果贴上来格式全乱了,只得不弄表格了。表格中官网的事件不是最新的,比最新的少2个,具体我会另发一篇文章说明。

     

    UI/Application Exerciser Monkey

    用户界面/应用 锻炼者Monkey

     

    The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.

    Monkey 是一个运行在模拟器或者实际设备中的程序,它生成伪随机用户事件流,如点击、触摸、手势以及一些系统级事件。你可以通过Monkey以一种随机且可以重复的方式来对正在开发的程序进行压力测试

     

    Overview

    概述

    The Monkey is a command-line tool that you can run on any emulator instance or on a device. It sends a pseudo-random stream of user events into the system, which acts as a stress test on the application software you are developing.

    Monkey是一个可以运行在任何模拟器或者实际设备的命令行工具。它向系统发送伪随机用户事件流,来对正在开发的应用程序进行压力测试

     

    The Monkey includes a number of options, but they break down into four primary categories:

    Monkey包括许多选项,主要划分为四大类:

     

    1.Basic configuration options, such as setting the number of events to attempt.

    1.基本配置选项,如设置运行的事件数量。

    2. Operational constraints, such as restricting the test to a single package.

    2.运行限制,如限制只测试一个应用程序包。

    3. Event types and frequencies.

    3.事件类型和频率。

    4. Debugging options.

    4. 调试选项。

     

    When the Monkey runs, it generates events and sends them to the system. It also watches the system under test and looks for three conditions, which it treats specially:

    Monkey运行时,它生成事件并发送给系统。并且对测试运行中的系统的三种情况进行监测:

     

    If you have constrained the Monkey to run in one or more specific packages, it watches for attempts to navigate to any other packages, and blocks them.

    如果限制了Monkey运行在一个或多个设定的包,那么它会监视试图转到其它包的操作,并对其进行阻止。

    If your application crashes or receives any sort of unhandled exception, the Monkey will stop and report the error.

    如果应用程序崩溃或收到任何失控异常,Monkey会停止运行并报告错误。

    If your application generates an application not responding error, the Monkey will stop and report the error.

    如果应用程序产生了应用程序不响应的错误,Monkey会停止运行并报告错误。

     

    Depending on the verbosity level you have selected, you will also see reports on the progress of the Monkey and the events being generated.

    根据你设定的不同级别,你将会在命令行中看到Monkey产生的事件和运行过程报告。

     

    Basic Use of the Monkey

    Monkey的基本用法

    You can launch the Monkey using a command line on your development machine or from a script. Because the Monkey runs in the emulator/device environment, you must launch it from a shell in that environment. You can do this by prefacing adb shell to each command, or by entering the shell and entering Monkey commands directly.

    可以通过开发机上的命令行或脚本来启动Monkey。由于Monkey运行在模拟器/实际设备,所以必须在相应环境的shell中来启动。可以在每条命令前加上adb shell,也可以进入Shell后直接输入Monkey命令。

     

    The basic syntax is:

    基础语法:

     

    $ adb shell monkey [options] 

     

    With no options specified, the Monkey will launch in a quiet (non-verbose) mode, and will send events to any (and all) packages installed on your target. Here is a more typical command line, which will launch your application and send 500 pseudo-random events to it:

    如果没指定options,Monkey将以无反馈模式启动,向你的设备或模拟器上安装的每一个程序发送事件。下面是一个更为典型的命令行示例,它启动指定的应用程序,并向其发送500个伪随机事件:

     

    $ adb shell monkey -p your.package.name -v 500

     

    Command Options Reference

    命令选项参考

    The table below lists all options you can include on the Monkey command line.

    下面的表包含了可以在Monkey命令中所有可选项。

    General:

    --help

    Prints a simple usage guide.

    打印一个简单的使用指导

    -v

    Each -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都将增加verbosity levelverbosity的意思是冗余,具体意思就是关于测试信息的多少,level越高,测试信息详细)。level0(默认)提供涵盖启动通知、测试完成和最结果的少许信息。Level 1提供了更多运行时关于测试的详细信息,比如每个正在发送activities的事件。Level2提供更多设置信息详情,如测试中被选中的或未被选中的activities


    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的执行速度。 

    如果未设置,将不会产生延迟,事件会以尽可能快的速度产生。

    --pct-touch 

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

    调整触摸事件百分比(触摸事件是一个在屏幕单一位置的按下-抬起事件)

    --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.) 

    调整手势事件百分比(手势事件是由一个在屏幕某处的按下事件、一系列的伪随机移动、一个抬起事件组成)即一个滑动操作,但是是直线的,不能拐弯

    --pct-trackball 

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

    调整轨迹球事件百分比(轨迹球事件包括一个或多个随机移动,有时还伴有点击。轨迹球现在智能手机上已经没有了,就是类似手柄的方向键一样)它在monkeyrunner可以画折线,用在图形解锁上

    --pct-nav 

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

    调整基本导航事件百分比(导航事件包括上下左右,如方向输入设备的输入)老手机的上下左右键,智能机上没有

    --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.) 

    调整主要导航事件百分比(这些导航事件通常会引发UI的事件,例如5-way pad的中间键、回退键、菜单键)

    --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 will only allow 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将只允许系统访问这些包中的activities。如果你的应用程序需要访问其他包的activities(如选择一个联系人)你也需要指定这些包。如果不指定任何包,Monkey将允许系统启动所有包里的activities。指定多个包时,需要使用多次-p选项,每个包配置一次-p

    -c 

    If you specify one or more categories this way, the Monkey will only allow 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将只允许系统访问被这些类别中的某个类别列出的activities。如果未指定类别,Monkey将选择Intent.CATEGORY_LAUNCHERIntent.CATEGORY_MONKEY中列出的类别。要指定多个类别,需要使用多次-c选项,每个类别配置一次-c


    Debugging

    --dbg-no-events

    When 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秒或更长时间的非零值一起使用。从而提供一个可以监视应用程序所调用包之间的转换的环境。

    --hprof

    If 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. See Traceview for more information on trace files. 

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

    --ignore-crashes

    Normally, 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-timeouts

    Normally, 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-exceptions

    Normally, 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. 

    通常,当应用程序产生任何权限错误时Monkey会停止运行,如尝试启动一个需要某个权限的activity。如果设置此项,Monkey会继续向系统发送事件,直到计数完成。

    --kill-process-after-error

    Normally, 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-crashes

    Watches 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-dbg

    Stops the Monkey from executing until a debugger is attached to it.

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



    一个例子:

    monkey -p com.zhenhua.song -s 23 --throttle1000 --ignore-crashes --ignore-timeouts -v -v -v 100000>/data/local/tmp/log.txt 2>&1 &

     

    -p com.zhenhua.song 包名com.zhenhua.song

    -s 23 seed值为23

    --throttle1000 每个事件之间的延迟1000毫秒

    --ignore-crashes --ignore-timeouts 应用程序如果出现崩溃或超时,Monkey将继续执行直到完成100000个事件

    -v -v -v 最详细的LOG级别

    1000000 执行10万个事件(单个应用程序建议10W,整机50W

    重定向输出(日志)

    /data/local/tmp/log.txt 将日志写到手机的该目录和文件

    2>&1 指将标准信息输出路径指定为错误信息输出路径,也就是都输出在一起(1> 指标准信息输出路径,默认输出方式;2> 指错误信息输出路径)

    & 后台运行,指一旦Monkey测试开始了,之后可以拔掉数据线,不会影响Monkey测试


    6.2号更新:(摘自搜狗微信公众号)

    通过批处理命令使Monkey不停运行:


    :loop

    adb shell monkey -p com.zhenhua.song -s %random% -v 10000 >%random%.txt

    ping -n 15 127.1 >null

    adb reboot

    ping -n 120 127.1 >null

    goto loop

     

    6.28号更新:如何停止正在运行的Monkey?http://www.cocoatest.com/sc/monkey/

    有时候设置的运行次数太多了,一直停不下来,因为monkey运行在手机系统里,即使拔掉连接线,照样在手机上运行,因此,我们把手机理解为一台电脑安装了一个linux系统,把monkey运行的进程杀死,这样就能停止monkey运行了

    <1>找进程

    adb shell ps | grep monkey

    返回来的第一个数字,即是monkey的进程号;

    <1>杀进程

    adb shell kill [刚才查到的进程号]

    同理结束其他进程,和其他应用也可用此法。转自:

  • 相关阅读:
    重拾web开发JavaScript复习
    Linq GroupBy
    Gotchas 31对目标类型为指涉物为常量的指针类型的类型转换的认识误区
    感谢你遇到的问题
    IDisposable模式的一点理解
    感谢你遇到的问题(2)
    .Net通过OutLook发送邮件,附件的名称太长会显示乱码
    深度学习利器之自动微分(1)
    建议转载的发在文章(Aticles)而不是随笔(Posts)内
    Forum,ForumGroup和my forum的汉译
  • 原文地址:https://www.cnblogs.com/songzhenhua/p/9312811.html
Copyright © 2011-2022 走看看