Introduction to Monkey Testing

Source: Internet
Author: User

Automated testing on Android phones, monkey is much more useful than cts,android unittest, and he is actually inheriting a shell command from the ADB shell.

The related principles of a monkey test

The principle of monkey testing is to use the socket communication method to simulate the user's key input, touch screen input, gesture input, etc., to see how long the device will be abnormal. When the monkey program is running in a simulator or device, it generates random pulses when a user starts a click, touch, gesture, or some system-level event, so you can use monkey to load test your software with a random, repetitive approach.

Ii. Introduction of Monkey procedure

1) The Monkey Program is provided by the Android system, written in the Java language, the storage path in the Android file system is:/sdk/sdk/tools/lib/monkey.jar; the corresponding way:

Note that my SDK is on the F-drive.

2) Monkey.jar Program is a shell script named "Monkey" to start execution, shell script in the Android file system storage path is:/sdk/sdk/tools/bin/monkey;

This allows the monkey to be tested by executing in the cmd window: adb shell Monkey {+ command arguments}.

What if I don't use monkey???

Iii. simple Help for the monkey command

To get the simple help that comes with the Monkey command, execute the command in CMD:

ADB Shell Monkey–help

This way, there are parameters to his various prompt commands.

I have a brief introduction to its various parameters here.

1) Parameter:-P

The parameter-P is used for constraint restrictions, and this parameter specifies one or more packages (the package, or app). Specified

After the package, 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.example.sellclientapp 100

Description: Com.example.sellClientAPP is the package name, 100 is the event count (i.e. let the monkey program simulate 100 random user events).

* Specify multiple packages: adb shell monkey-p com.htc.weather–p com.htc.pdfreader-p com.htc.photo.widgets 100:

* Do not specify package: adb shell Monkey 100

Description: Monkey randomly launches the app and sends 100 random events.

* To view all the packages in the device, execute the following command in the cmd window:

>ADB Shell

#cd Data/data

#ls

My phone doesn't have root, so I can't use this property anymore.

2) Parameter:-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:

Log levels Level 0

Sample adb shell monkey-p com.htc.weather–v 100

Explaining the default values, providing only a small amount of information, such as startup hints, test completion, and final results, is useful for debugging.

Log levels Level 1

Sample adb shell monkey-p com.htc.weather–v-v 100

Description provides a more detailed log, including each event message sent to the activity

Log Levels Level 2

Sample adb shell monkey-p com.htc.weather–v-v–v 100

Description of the most detailed log, including the selected/unchecked activity information in the test

-S

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.htc.weather–s 10 100

Monkey test 2:adb Shell monkey-p com.htc.weather–s 10 100

The effect of the two Tests is the same, because the simulated sequence of user actions (a sequence of operations consisting of each operation in a certain order) is the same. Operation sequence

Columns are randomly generated, but as long as we specify the same seed value, we can guarantee that the random sequence of operations generated by the two Tests is exactly the same, so this sequence of operations is pseudo-

the machine;

Monkey is very good, very strong, I these experiments are his fur, also hope to get cattle people testify.

Good study day day up.

Introduction to 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.