Android command monkey stress test, details

Source: Internet
Author: User

Shell, monkey, system, Android, file system monkey, example, Introduction

1. Introduction to monkey testing

Monkey testing is an automated test method on the Android platform. Using the monkey program, you can simulate the user's touch screen, sliding trackball, and buttons to press the program on the device.

 

Force Testing detects how long an exception occurs in the program.

 

Ii. Monkey program Introduction

1) The Monkey program is provided by the Android system and written in Java. The storage path in the android file system is/system/framework/monkey. jar;

2) The monkey. Jar program is started and executed by a shell script named "monkey". The storage path of the shell script in the android file system is/system/bin/monkey;

 

In this way, you can perform the monkey test by executing: ADB shell monkey {+ command parameter} in the CMD window.

 

Iii. Simple monkey Command help

To obtain the simple help provided by the monkey command, run the following command in cmd:

ADB shell monkey-help

4. Introduction to monkey Command Parameters

1) parameter:-P

Parameter-P is used to restrict the use of this parameter to specify one or more packages (that is, Apps ). Specify

After the package, Monkey only allows the system to start the specified app. If no package is specified, monkey allows the system to start all apps on the device.

* Specify a package: ADB shell monkey-P com. HTC. Weather 100

Note: COM. HTC. Weather is the package name, and 100 is the event count (that is, let the monkey program simulate 100 random user events ).

* Specify multiple packages: ADB shell monkey-P com. HTC. Weather-P com.htc.pdf reader-P com. HTC. Photo. widgets 100

* Package not specified: ADB shell monkey 100

Note: The Monkey randomly starts the app and sends 100 random events.

* To view all the packages on the device, run the following command in the CMD window:

> ADB Shell

# Cddata/Data

# Ls

2) parameter:-V

This parameter is used to specify the level of feedback information (the information level is the log details), which is divided into three levels. The corresponding parameters are shown in the following table:

Log Level level0

Example ADB shellmonkey-P com. HTC. Weather-V 100

The default value. Only a small amount of information is provided, such as the startup prompt, test completion, and final result.

 

Log Level 1

Example ADB shellmonkey-P com. HTC. Weather-v 100

Provides detailed logs, including information about each event sent to the activity.

 

Log Level 2

Example ADB shellmonkey-P com. HTC. Weather-v 100

Describe the most detailed logs, including the activity information selected or not in the test.

 

3) parameter:-S

Specifies the seed value of the pseudo-random number generator. If seed is the same, the event sequence generated by the two monkey tests is the same.

* Example:

Monkey Test 1: ADB shell monkey-P com. HTC. Weather-S 10 100

Monkey Test 2: ADB shell monkey-P com. HTC. Weather-S 10 100

The effects of the two tests are the same, because the simulated user operation sequence (each operation is composed of a series of operations in a certain sequence, that is, a sequence) is the same. Operation Sequence

 

Although columns are randomly generated, as long as we specify the same seed value, we can ensure that the random operation sequence generated by the two tests is identical, so this operation sequence is pseudo-

 

Host;

 

4) parameter: -- throttle <millisecond>

Used to specify the latency between user operations (that is, events), in milliseconds;

* Example: ADB shell monkey-P com. HTC. Weather-Throttle 3000 100

5) parameter: -- ignore-crashes

Used to specify whether the monkey stops running when the application crashes (Force & close error. If this parameter is used, even if the application crashes, the monkey still sends the event, directly

 

The event count is complete.

* Example 1: ADB shellmonkey-P com. HTC. Weather -- ignore-crashes 1000

During the test, even if the weather program crashes, monkey continues to send events until the number of events reaches 1000;

* Example 2: ADB shellmonkey-P com. HTC. Weather 1000

If the weather program crashes during the test, the monkey stops running.

 

 

6) parameter: -- ignore-timeouts

It is used to specify whether the monkey stops running when the application has an ANR (application No responding) error. If this parameter is used, even if an ANR error occurs in the application,

 

Monkey still sends events until the event count is complete.

 

7) parameter: -- ignore-security-Exceptions

Used to specify whether the monkey stops running when an application encounters a license error (such as a certificate license or a network license. If this parameter is used, even if a license error occurs in the application,

 

Monkey still sends events until the event count is complete.

 

8) parameter: -- kill-process-after-Error

Specifies whether to stop an application when an error occurs. If this parameter is specified, when an application error occurs, the application stops running and remains in the current State (note:

 

The application is only static when an error occurs, and the system does not end the process of the application ).

 

9) parameter: -- Monitor-native-crashes

Specifies whether to monitor and report local code that crashes the application.

 

10) parameter: -- PCT-{+ event category} {+ event category percentage}

Used to specify the percentage of events of each category (in the monkey event sequence, the percentage of events of this category to the total number of events)

 

Parameters:

Instructions for use:

Example:

 

-- PCT-touch {+ percentage}

Adjust the percentage of touch events (a touch event is a down-up event that occurs at a single location on the screen)

ADB shell monkey-P com. HTC. Weather -- PCT-touch 10 1000

 

-- PCT-motion {+ percentage}

Adjust the percentage of Action events (Action events are composed of a down event, a series of pseudo-random events, and an up event somewhere on the screen) ADB shell monkey-P

 

Com. HTC. Weather -- PCT-motion 20 20 1000

 

-- PCT-trackball {+ percentage}

Adjust the percentage of track events (track events consist of one or more random moves, sometimes with clicks)

ADB shell monkey-P com. HTC. Weather -- PCT-trackball 30 1000

-- PCT-nav {+ percentage}

 

Adjust the percentage of "Basic" navigation events (navigation events are composed of up/down/left/right from the input device)

ADB shell monkey-P com. HTC. Weather -- PCT-nav 40 1000

 

-- PCT-majornav {+ percentage}

Adjust the percentage of "Main" navigation events (these events usually lead to operations in the graphic interface, such as the intermediate buttons of the 5-way keyboard, the back button, and the menu button)

ADB shell monkey-P com. HTC. Weather -- PCT-majornav 50 1000

 

-- PCT-syskeys {+ percentage}

Adjust the percentage of system key events (these keys are usually retained and used by the system, such as home, back, start call, end call, and volume control keys)

ADB shell monkey-P com. HTC. Weather -- PCT-syskeys 60 1000

 

-- PCT-average witch {+ percentage}

Adjust the percentage of started activity. During the random interval, monkey will execute a startactivity () call as a method to overwrite all the activities in the package to the maximum extent possible.

ADB shell monkey-P com. HTC. Weather -- PCT-modified witch 70 1000

 

-- PCT-anyevent {+ percentage}

Adjust the percentage of other types of events. It includes all other types of events, such as buttons, other infrequently used device buttons, and so on.

ADB shell monkey-P com. HTC. Weather

 

-- PCT-anyevent 100 1000 * specifies the percentage of multiple types of events:

ADB shell monkey-P com. HTC. Weather -- PCT-anyevent 50 -- PCT-Restart witch 50 1000

Note: The percentage of each event type cannot exceed 100%;

 

Related Article

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.