Monkey test learning Summary

Source: Internet
Author: User


I.Install, configure, and connect devices

 

1. Download the android SDK and decompress the folder named adt-bundle-windows-x86.

 

2. configure environment variables, go to computer properties-advanced-environment variables-system variables, add paths for platform-tools and tools in the adt-bundle-windows-x86 \ SDK directory to path, such as variable values in, separate them with other paths.

 

3. Connect the andriod device to the computer through USB cable, or install 91 assistant on the Samsung pad and enable it, install 91 assistant on the computer, and use WiFi connection (no access is made temporarily ).

 

4. Go to the CMD environment and operate monkeytest.

A. Enter the command ADB devices.

The device connected to the computer is displayed, for example:

 

B. Enter the command: ADB Shell

If you can connect to the pad, the following will be displayed: Ctrl + C can exit.

 

C. Enter the ADB shell monkey [parameter] command to perform a monkey test. Alternatively, enter adbshell and enter monkey.
[Parameter]. The ADB shell is omitted.

II.Monkey Command Parameters

To obtain the simple help provided by the monkey command, run the following command:
ADB shell monkey-help

Usage: Monkey [-P allowed_package [-pallowed_package]...]
[-C main_category [-C main_category]...]
[-- Ignore-Crashes] [-- ignore-timeouts]
[-- Ignore-security-exceptions]
[-- Monitor-native-Crashes] [-- ignore-native-crashes]
[-- Kill-process-after-Error] [-- hprof]
[-- PCT-touch percent] [-- PCT-motion percent]
[-- PCT-trackball percent] [-- PCT-syskeys percent]
[-- PCT-nav percent] [-- PCT-majornav percent]
[-- PCT-Reset witch percent] [-- PCT-flip percent]
[-- PCT-anyevent percent]
[-- PKG-blacklist-file package_blacklist_file]
[-- PKG-whitelist-file package_whitelist_file]
[-- Wait-dbg] [-- dbg-no-events]
[-- Setup scriptfile] [-F scriptfile [-F scriptfile]...]
[-- Port port]
[-S seed] [-V [-v]...]
[-- Throttle millisec] [-- randomize-Throttle]
[-- Profile-Wait millisec]
[-- Device-sleep-time millisec]
[-- Randomize-script]
[-- Script-log]
[-- Bugreport]
Count

1. Parameter:-P
Parameter-P is used to restrict the use of this parameter to specify one or more packages (that is, Apps ).
* 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: adbshell monkey-P com. HTC. Weather-P com.htc.pdf reader-pcom. HTC. Photo. widgets 100
* Package not specified: adbshell monkey 100
Note: The Monkey randomly starts the app and sends 100 random events.
* To view the application package name and run SDK \ tools \ monitor. bat, the package name is displayed on the page when the program is running.

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 0
Example ADB shell monkey-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 shell monkey-P com. HTC. Weather-v 100
Provides detailed logs, including information about each event sent to the activity.

Log Level 2
Example ADB shell monkey-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: adbshell 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. Although the operation sequence is 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, therefore, this operation sequence is pseudo-random;

4. Parameter: -- throttle <millisecond>
Used to specify the latency between user operations (that is, events), in milliseconds;
* Example: adbshell 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, Monkey sends an event even if the application crashes until the event count is complete.
* Example 1: ADB shell monkey-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 shell monkey-P com. HTC. Weather 1000
If the weather program crashes during the test, the monkey stops running.

6. Parameter: -- ignore-timeouts
Specifies whether the monkey stops running when an ANR (applicationno responding) error occurs in the application. If this parameter is used, the monkey sends an event even if an ANR error occurs in the application 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, the monkey sends an event even if a license error occurs in the application 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, 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)

-- 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) adbshell 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, endcall, 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%;

11. Configure the blacklist as follows:

1. Create a New TXT file named blacklist.txt;

2) The content of the text file is the package name of the APK. The format requirements are as follows: (enter the new APK package name in line feed)

Com. Android. package1

Com. Android. package2

Com. Android. package3

3) Push the text file to the mobile phone:

ADB push into blacklist.txt]/Data Directory (you can also put it under the SD card directory)

4) perform the monkey test.

12. How to set the whitelist:

The method for adding a whitelist is the same as that for adding a blacklist. You only need to change the text file name to whitelist. The command used is -- PKG-whitelist-file.
/Data/whitelist.txt

Note:: Both the blacklist and whitelist cannot be used at the same time or with the-P [package name] command.

 

Iii. Test Results

 

1. Save the file to the device Folder:

>/Sdcard/monkey report.txt

Example:

Monkey-P [APK package name] -- throttle 1000-s 10000 -- ignore-crashes -- ignore-timeouts -- ignore-security-exceptions -- ignore-native-crashes -- Monitor-native-crashes -v 150000>/sdcard/monkeyreport.txt

 

2. Test Result Analysis

Search for keywords in the log to determine the type of the crash issue and the APK application:

1) exception: keyword of program crash.

The log is aborted due to an exception. You only need to search for the exception to find the log.

2) ANR: The program has no response keyword.

It is a non-responsive log of a program attached to me. You only need to search for ANR (remember to write it in uppercase) to search for this log.

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.