Getting Started with Android monkey testing

Source: Internet
Author: User

Monkey是一款通过命令行来对我们APP进行测试的工具,可以运行在模拟器里或真机上。它向系统发送伪随机的用户事件流,实现对正应用程序进行压力测试。

Monkey parameter Daquan

-p < allowable list of package names >

Use this parameter to specify one or more packages. After the package is specified, monkey will only allow the system to launch the specified app. If you do not specify a package, Monkey will allow the system to boot all apps in the device.

Specify a package: adb shell monkey-p com.shjt.map 100

Specify multiple packages: adb shell monkey-p fishjoy.control.menu–p com.shjt.map 100

-V

Used to specify the level of feedback information (the level of information is the verbosity of the log), with a total of 3 levels, respectively, with the corresponding parameters as shown in the following table:

Level 0:adb Shell monkey-p com.shjt.map-v 100//default, provides only a small amount of information such as startup hints, test completion, and final results

Level 1:adb Shell monkey-p com.shjt.map-v-V 100//provides more detailed logs, including each event message sent to activity

Level 2:adb Shell monkey-p com.shjt.map-v-v-v 100//The most detailed log, including the selected/unchecked activity information in the test

-S (random number Seed)

Used to specify the seed value of the pseudo-random number generator, and if the seed is the same, the sequence of events produced by the two monkey tests is the same. Example:

Monkey test 1:adb Shell monkey-p com.shjt.map–s 10 100

Monkey test 2:adb Shell monkey-p com.shjt.map–s 10 100


--throttle < milliseconds >

Used to specify the delay between user actions (that is, the event), in milliseconds, and if this parameter is not specified, Monkey generates and sends the message as quickly as possible.

Example: adb shell monkey-p com.shjt.map--throttle 3000 100

一、九个 events and Percent control

1, nine events

--pct-touch <percent> 0
Adjust the percentage of touch events (Touch event is a down-up event that occurs in a single location on the screen) (--click event, involving down, up)

--pct-motion <percent> 1
Adjust the percentage of action events (an action event consists of a down event, a series of pseudo-random events, and an up event on the screen) (--Note: Move event involving down, up, move three events)

--pct-trackball <percent> 2
Adjust the percentage of track events (track events consist of one or several random movements, sometimes accompanied by clicks)--(Trackball)

--pct-nav <percent> 3
Adjust the percentage of basic navigation events (navigation events consist of up/down/left/right from the direction input device)

--pct-majornav <percent> 4
Adjust the percentage of primary navigation events (these navigation events usually trigger actions in the graphical interface, such as: 5-way keyboard, Fallback button, menu button)

--pct-syskeys <percent> 5
Adjust the percentage of the System key event (these keys are usually reserved for use by the system, such as home, back, Start call, End call, and volume control keys)

--pct-appswitch <percent> 6
Adjusts the percentage of startup activity. In a random interval, monkey executes a startactivity () call as a way to maximally cover all activity in the package. (Jump from one activity to another activity)

--pct-flip <percent> 7
Adjusts the percentage of the keyboard rollover event.

--pct-anyevent <percent> 8
Adjusts the percentage of other types of events. It includes all other types of events, such as keystrokes, other infrequently used device buttons, and so on.

The red numbers correspond to the percentages below. For example, 0:15.0%, which represents the allocation of--pct-touch event 15%. Test 100 Allocations 15 times test down-up.

2. Percent control

If the above parameters are not specified in the monkey parameter, these actions are randomly assigned, and the sum of each of the 9 actions is assigned as a percentage of 100%, we can control the percentage of each event by adding a command option, which allows the operation to be limited to a certain extent.

Let's take a look at the non-action percent control, the system default allocation event percentage

Command: adb shell monkey-v-P Com.panscarlic.pay 500

Specifying events, controlling event percentages

Command: adb shell monkey-v-P com.panscarlic.pay--pct-anyevent 100 500

commonly used in testing

adb shell monkey–p com.panscarlic.pay–v 1000
adb shell monkey–p com.panscarlic.pay–-throttle 100–-pct-touch 50–-pct-motion 50–v–v
adb shell monkey-p com.panscarlic.pay--throttle 380-v-S 3500 300000 > D:\monkey_log.txt

Getting Started with Android monkey testing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.