Monkey Android stress testing tool

A, Monkey defined
explore what software testing tools, paper describes Monkey tool. Monkey Android platform testing is a test automation means to pressure test program on the device by a user touches the screen simulation Monkey, sliding, and other key operation program, how long will the program detects abnormality occurs. Each operation time interval is set by the parameter our testers, usually, we set the time interval of each operation is 500ms.

Program Description Monkey:
Monkey Android system comes with the program, written in the Java language, storage path in the Android file system is: /system/framework/monkey.jar

12

Note: Monkey.jar program is called "monkey" to start the execution of Shell scripts, shell scripts stored in a way Android file system are: / system / bin / monkey;
so that you can perform in the CMD window: adb shell monkey {+} command parameters Monkey be tested.

Two, Monkey test
1, Monkey test preparation
prior to execution Monkey tests, we need to download the ADB tool, and install JDK v1.5 or later.
Adb tool is Android debugging tools provided by Google, you can access the phone through linux command line.
After installing the JDK environment, download adbtools, we need to configure the environment variables, add storage path adbtools to the path, we can begin Monkey test.
Note: You need root privileges.
2, the implementation Monkey test
test command
through the above we have learned, started by adb command test monkey, monkey basic format of the command is: adb shell monkey -p com.android.xxx -v 180000 --throttle 500. This command, -p represents a package that is the object of our monkey test, a command can have multiple packages, each package is a need to add a -p, such as adb shell monkey -p Pack 2 ... 1 -p package. .Com.android.xxx is what we need to do target testing, obtain information about the package name will be detailed below.
-v behalf returns the result of the level of detail, divided into three, namely, level 1 level 2 level 3, the higher the level, the log will return to a more detailed level 1 is -v, -v -v grade 2, grade 3 as -v -v -v.
number of executions 180,000 behalf, be modified according to actual testing needs.
-throttle 500 representative of the time interval, i.e. the time interval of each operation. In order to better simulate a user operation, it is necessary to increase the time interval between each operation, in milliseconds, the meaning of this command is to increase the time interval of 500ms.

Get the package name of the
acquired package name command, adb shell ls / data / data , this command can show the package inside the phone, and then find they need to test the package was tested in the list.
If the phone memory and some more packages in the cmd window view is not convenient. Package list can be exported as a txt file and look for package information: adb shell LS / the Data / the Data> D: \ xxx.txt 3, Monkey analysis of test results after the test to get Monkey log, we can be judged by a few key words whether the test passed. 1) Monkey finished with Notepad to open LOG, most lower end of the log to see whether there is similar to the following fields: ## Network stats: the Elapsed Time = 3799ms (3799ms Mobile, 0ms wifi, 0ms not Connected) // Monkey Finished this field show that the Monkey times through the test, no abnormal 2) CRASH Similarly, after getting LOG, search for "CRASH" field, if there is to search results, it indicates that, during the test, the test subjects had an error and, therefore, the test fails. CRASH //: com.onekchi.downloadmanager (pid 12919) 3) the NOT RESPONDING found in the log in the prime field, if there is a search result, it means that the testing process, the test subjects had no response process and, therefore, the test fails. 4) The above information can not be searched
2













This happens, usually external causes rather than the program itself causes. For example, during the test, the computer power off. Or testing out of memory and so on, the result of obsolete and needs to re-test.

Third, the test case
for the downloaded Butler monkey test, the test time of 10 hours.
Testing Procedure: 1, mobile phone connected to the computer, view the downloaded housekeeper specific package name by adb shell ls / data / data.

12Download Butler can see the package name by drawing in particular on: com.onekchi.downloadmanager

Then at the command line, type:
adb shell Monkey -p com.onekchi.downloadmanager
-v -v -v 180000 -throttle 500> D: \ monkeytest.txt
thus test start, end monkeytest.txt found in the D drive and open access, according to the results of lading can be.

Four, Monkey summary parameters
1, parameters: -p
parameter -p constraints for specifying this parameter with one or more packets (the Package, i.e. App). Designated
after the package, Monkey will only allow the system to start the specified APP. If no packet, Monkey will allow the system to start APP all devices.
* Specify a package: adb shell monkey -p com.htc.Weather 100
Description: com.htc.Weather for the package name, the event count is 100 (ie 100 times simulation program so that Monkey random user events).
* Specify multiple packages: the adb the shell com.htc.Weather Monkey -p -p -p com.htc.pdfreader com.htc.photo.widgets 100
* not specified package: adb shell monkey 100
Description: Monkey and transmits random start APP 100 random events.
* To see all of the equipment package, execute the following command in the CMD window:
> adb shell
#cd the Data / the Data
#ls

2, parameters: -v
specifies the level of feedback information (log information level is the level of detail), a total of three sub-levels, respectively corresponding to the parameters as follows:
Log Level Level 0
Example adb shell monkey -p com.htc .Weather -v 100
Description default value, only a small amount of information on the boot prompt, complete and final test results, etc.

Log Level 1 Level
exemplary adb shell monkey -p com.htc.Weather -v -v 100
instructions provide a more detailed log, each event comprises information transmitted to the Activity

Log Level 2 Level
exemplary adb shell monkey -p com.htc.Weather -v -v -v 100
described most detailed log, including the test checked / unchecked information Activity

3, parameters: -s
specifies the pseudo-random number generator seed value, and if the same seed, the two test sequence of events generated Monkey also the same.
* Example:
Monkey Test. 1: Monkey -p com.htc.Weather the adb the shell -s 100 10
Monkey Test 2: adb shell monkey -p com.htc.Weather -s 10 100
results of two tests are the same, because the analog user operation sequence (a series of operations for each operation consisting in certain sequence, i.e. a sequence) is the same. Although the sequence of operations is randomly generated, but if we specify the same Seed value, to ensure that the random sequence of operations can generate two tests are identical, so the operation of the pseudo random sequence;

4, parameters: --throttle <msec>
is used to specify the delay between user operation (i.e. incident), in milliseconds;
* Example: adb shell monkey -p com.htc.Weather -throttle 3000 100

5, parameters: --ignore-crashes
is used to specify when (Force & Close error) application crashes, Monkey has stopped running. If you use this parameter, even if the application crashes, Monkey will still send events until the event count is completed.
* Example 1: adb shell monkey -p com.htc.Weather --ignore -crashes 1000
during the test even if the Weather program crashes, Monkey will still continue to send events until the number of events reaches 1000;
* Example 2: adb shell monkey -p com.htc.Weather 1000
testing process, if Weather crashes, Monkey will stop running.

6 parameters: --ignore-timeouts
used to specify when the application occurs ANR (Application No Responding) errors, Monkey whether to stop the run. If you use this parameter, ANR even if the application error occurs, Monkey will still send events until the event count is completed.

7, parameters: --ignore-security-exceptions
is used to specify when (e.g., license certificates, licenses, etc. Network) application license error, whether Monkey stopped. If you use this parameter, even if the license application error occurs, Monkey will still send events until the event count is completed.

8, parameters: --kill-process-after-error
is used to specify when an application error has occurred, whether to stop its operation. If specified, when an application error occurs, the application stops running and maintaining the current status (Note: The application is still only at the time the error occurred, the system does not end the process of the application).

9, parameters: --monitor-native-crashes
to specify whether to monitor and report the native code of the application crashes.

10, parameters: --pct - {+} {+ Event Type Event Category Percentage}
specifies the percentage number of events in each category (in the Monkey sequence of events, the number of percentage of the total number of events such events)

Parameter:
Description:
Example:

--pct-touch {+} The percentage
adjustment percentage touch event (touch event is a down-up event, which occurs at a single location on the screen)
the adb the shell Monkey -p com.htc.Weather Touch-10-PCT 1000

--pct-motion {+} percentage
percentage adjustment operation event (an operation event of a screen somewhere down event, a series of events and a pseudorandom up of events) adb shell monkey -p com.htc.Weather - -pct-motion 20 1000

--pct-trackball {+} The percentage
adjustment percentage track events (track events by one or more random mobile composition, sometimes accompanied by clicks)
the adb the shell Monkey -p com.htc.Weather Trackball 30-1000-PCT
percentage --pct-nav {+}

Adjusting the percentage of the "basic" navigation event (navigation event from an input device by the direction up / down / left / right composition)
the adb the shell Monkey -p com.htc.Weather NAV-40 1000-PCT

--pct-majornav {+} The percentage
adjustment percent "primary" navigation event (typically initiates the operation of these navigation event graphical interface, such as: 5-way button keyboard intermediate rewind button, the menu button)
the adb the shell Monkey - p com.htc.Weather --pct-majornav 50 1000

--pct-syskeys {+} percentage
percentage adjustment "system" key event (these buttons are typically reserved for use by the system, such as Home, Back, Start Call, End Call , and volume control keys)
the adb the shell Monkey -p COM. htc.Weather --pct-syskeys 60 1000

--pct-appswitch {+} The percentage
adjustment percentage of Activity started. At random intervals in, will perform a startActivity Monkey () call, as a method of maximally Activity package covering all
adb shell monkey -p com.htc.Weather --pct-appswitch 70 1000

{+} --pct-anyevent percentage
percentage adjustment of other types of events. It include all other types of events, such as: buttons, other less frequently used device buttons, etc.
adb shell monkey -p com.htc.Weather

--pct -anyevent 100 1000 * the specified percentage of the plurality of types of events:
the adb the shell com.htc.Weather -p-PCT-AnyEvent Monkey 50 50 1000-PCT-appswitch

Note: Total percentage of each type of event can not exceed 100%.

Guess you like

Origin www.cnblogs.com/georgexu/p/11223974.html