"Android Test" "section II" Monkey tool

Source: Internet
Author: User

Recently began to study the Android test Monkey tools, because the contact time is very short, there are many shortcomings, I hope to communicate with you more.

What is Monkey

Monkey is a command-line tool in Android that can be run in the emulator or in the actual device. It sends a pseudo-random message to the system

User event flow (such as key input, touch screen input, gesture input, etc.) to enable stress testing of the application under development.

Monkey testing is a fast and effective method to test the stability and robustness of the software.


what monkey to do

Monkey is a stress test gadget used primarily for Android stress testing, the main purpose of which is to test whether the app will crash.


Monkey Program Introduction

(1) Monkey program by the Android system, using the Java astonished words written, in the Android file system storage path is:/system/framework/monkey.jar;
(2) Monkey.jar program is a shell script named "Monkey" to start execution, shell script in the Android file system storage path is:/system/bin/monkey;
(3) Monkey command start mode:
A. Monkey test can be performed via the PC cmd window: adb shell monkey{+ Command parameter}

B. On the PC, the ADB shell enters the Android system and performs the monkey test by executing the monkey {+ command parameter} c. To execute the monkey command directly on the Android or emulator, you can install the Android Terminal module on the Android device. Pseudo-Device


architecture of the monkey

The Monkey runs on the device or emulator and can be run off the PC (the common practice is to use Monkey as a test tool for sending random key messages like the application under test. Verify that the application under test will flash or crash in the presence of these random inputs

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/8A/3B/wKioL1grxNXRobSdAACt4Y5LhQo502.png "title=" 263119-20160505223944482-1516389266.png "alt=" Wkiol1grxnxrobsdaact4y5lhqo502.png "/>


Monkey parameter Daquan

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8A/3E/wKiom1grxSGDmSHMAACAjjIjPVA969.png "title=" 263119-20160505230123154-1071480837.png "alt=" Wkiom1grxsgdmshmaacajjijpva969.png "/>

Monkey command, basic parameter introduction


-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

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 value, only start prompt, test

A small amount of information, such as trial completion and final results

Level 1:adb Shell monkey-p com.shjt.map-v-V 100//provides a more detailed log, including every

Event information sent to the activity


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

Unchecked activity information


-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



Monkey View Package name

1) Install APK package name Viewer in Phone

2) Androidmanifest.xml file view under source code


3) AAPT Command view


Monkey Log Analysis

Normally, if the Monkey test completes successfully, at the end of the log, the number of times the current execution event is printed and the time spent;//Monkey finished represents execution completion \

Abnormal conditions

Monkey test errors occur, the general analysis steps

Watch Monkey's log (note the first Swith and exception information, etc.)
1. Program unresponsive issue: Search the log for "ANR"
2. Crash: Search for "Exception" in the log (if a null pointer appears nullpointerexception) there must be a bug.

Monkey execution interrupt, the current number of executions can also be seen at the end of log



This article from the "Half wake half drunk half-floating" blog, please be sure to keep this source http://sweettesting.blog.51cto.com/12233355/1873367

"Android Test" "section II" Monkey tool

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.