Android monkey 命令详解
monkey 是一个运行在模拟器或者Android设备中可以产生类似用户点击、触摸、手势以及一些系统级的伪随机事件流的程序。
我们可以通过命令让monkey向模拟器或者Android设备发送伪随机事件流来对我们开发的App进行压力测试。
monkey的基本用法:
adb shell monkey [options] <event-count>
adb shell monkey 为固定语句, 这里是指让monkey向系统发送多少次伪随机事件,重点和关键在[options]选项中,这就引出了我们下面要介绍的
monkey 命令
Category | Option | Description |
---|---|---|
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. | |
Events | -s <seed> |
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. |
--throttle <milliseconds> |
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. | |
--pct-touch <percent> |
Adjust percentage of touch events. (Touch events are a down-up event in a single place on the screen.) | |
--pct-motion <percent> |
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 <percent> |
Adjust percentage of trackball events. (Trackball events consist of one or more random movements, sometimes followed by a click.) | |
--pct-nav <percent> |
Adjust percentage of "basic" navigation events. (Navigation events consist of up/down/left/right, as input from a directional input devic |