UI/Application测试利器Monkey

UI/Application Exerciser Monkey

UI/Application测试利器Monkey

转载:http://developer.android.com/guide/developing/tools/monkey.html

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 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命令的选项可分为四类:
Basic configuration options, such as setting the number of events to attempt.
1.基本配置选项,如设置产生事件的次数;
Operational constraints, such as restricting the test to a single package.
2.操作限制,如限制测试只能针对单一的包;
Event types and frequencies.
3.事件类型与频率;
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.
1.若你限制Monkey运行于一个或多个指定的包,Monkey监视那些尝试浏览其它包的情况,并阻塞;
If your application crashes or receives any sort of unhandled exception, the Monkey will stop and report the error.
2.若你的应用崩溃或者产生任何不可预期的异常,Monkey将停止并报错;
If your application generates an application not responding error, the Monkey will stop and report the error.
3.若你的应用产生一个应用没有响应的错误,则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.


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运行于模拟器/设备环境,你需要从shell中运行Monkey。所以需要先运行adb shell,然后运行每一个命令,或者运行adb shell + command。
The basic syntax is:
$ adb shell monkey [options] <event-count>
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:

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


详情请直接adb shell monkey -v查看详细命令组合。

你可能感兴趣的:(application)