Android之monkey测试!

转载自:http://hi.baidu.com/_soros521521/blog/item/693763d2f60e3d3006088b37.html
 
Overview
Monkey是在模拟器上或设备上运行的一个小程序,它能够产生为随机的用户事件流,例如点击(click),触摸(touch),挥手(gestures),还有一系列的系统级事件。你可以使用Monkey来给你正在开发的程序做随机的,但可重复的压力测试 。
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.

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

Basic configuration options, such as setting the number of events to attempt.Operational constraints, such as restricting the test to a single package.Event types and frequencies.Debugging options.

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:

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.If your application crashes or receives any sort of unhandled exception, the Monkey will stop and report the error.If your application generates an application not responding error, the Monkey will stop and report the error.

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

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.

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

Monkey是运行在模拟器或设备上的一个程序,用来伪随机地模拟点击和触摸等用户事件,就如其它许多系统事件一样。Monkey可以用于对我们开发的应用程序进行随机和重复的压力测试。

简介

Monkey是一个命令行工具,可以运行在模拟器里或实际设备中。它向系统发送伪随机的用户事件流,实现对正在开发的应用程序进行压力测试。Monkey包括许多选项,它们大致分为四大类:

· 基本配置选项,如设置尝试的事件数量。

· 运行约束选项,如设置只对单独的一个包进行测试。

· 事件类型和频率。

· 调试选项。

Monkey运行的时候,它生成事件,并把它们发给系统。同时,Monkey还对测试中的系统进行监测,对下列三种情况进行特殊处理:

· 如果限定了Monkey运行在一个或几个特定的包上,那么它会监测试图转到其它包的操作,并对其进行阻止。

· 如果应用程序崩溃或接收到任何失控异常,Monkey将停止并报错。

· 如果应用程序产生了应用程序不响应(application not responding)的错误,Monkey将会停止并报错。

按照选定的不同级别的反馈信息,在Monkey中还可以看到其执行过程报告和生成的事件。

Monkey基本用法

可以通过开发机器上的命令行或脚本来启动Monkey。由于Monkey运行在模拟器/设备环境中,所以必须用其环境中的shell来进行启动。可以通过在每条命令前加上adb shell来达到目的,也可以进入Shell后直接输入Monkey命令。基本语法如下:

$ adb shell monkey [options]

如果不指定options,Monkey将以无反馈模式启动,并把事件任意发送到安装在目标环境中的全部包。下面是一个更为典型的命令行示例,它启动指定的应用程序,并向其发送500个伪随机事件:

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

命令选项参考


Android之monkey测试!_第1张图片


你可能感兴趣的:(android,shell,测试,application,constraints,events)