Android Monkey Stress Test Detailed introduction _android

Source: Internet
Author: User
Tags touch

Monkey is a command-line tool provided by the Android SDK that can be easily and conveniently run on any version of the Android emulator and physical device. Monkey will send a pseudo-random stream of user events for the app to do stress testing

Reading Table of Contents

    1. Environment construction
    2. What is Monkey
    3. What monkey used to do?
    4. Monkey Program Introduction
    5. Monkey Architecture
    6. Monkey weakness
    7. Monkey parameter Daquan
    8. Introduction to basic parameters of Monkey command
    9. Monkey instance
    10. Monkey View Package Name
    11. Monkey Log Analysis
    12. Must pay attention to crash

Environment construction

Install the Android SDK and configure environment variables

Http://pan.baidu.com/s/1jIlifbS

What is Monkey

As the name suggests, Monkey is a monkey, monkey test, just like a monkey, in front of the computer, knock on the keyboard in the test. Monkeys don't know anything, they just knock.

Through the monkey program to simulate the user touch screen, sliding trackball, buttons and other operations to the device on the test of the program, the test program how long time will occur abnormal

What monkey used to do?

Monkey is primarily used for automated pressure test gadgets for Android, the main purpose of which is to test whether the app will crash.

Monkey Program Introduction

(1) The Monkey Program is brought by the Android system, written in Java astonished, and stored in the Android file system:/system/framework/monkey.jar;

(2) The Monkey.jar program is a shell script called "monkey" to launch execution, the shell script in the Android file system is stored in the path:/system/bin/monkey;

(3) Monkey command start mode:

A) can be performed through the PC cmd window: adb shell Monkey {+ command parameters} for monkey testing

b the ADB shell enters the Android system on the PC and performs monkey testing by executing monkey {+ command parameters}

C Execute the monkey command directly on the Android or emulator to install the Android terminal emulator on the Android machine

Monkey Architecture

Monkey is run 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 applications to be tested.) Verify that the application being tested will flash or crash in front of these random inputs

Monkey weakness

Monkey Although the key message can be sent according to a specified command script, it does not support conditional judgment, nor does it support reading the information of the interface to be tested to perform the validation operation.

Monkey parameter Daquan

Introduction to basic parameters of Monkey command

-P < allowable list of package names >

Specify one or more packages with this parameter. After the package is specified, monkey will only allow the system to start the specified app. If you do not specify a package, Monkey will allow the system to start all the 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

To specify the level of feedback information (information level is the degree of detail of the log), a total of 3 levels, the corresponding parameters are as shown in the following table:

Level 0:adb Shell monkey-p com.shjt.map-v 100//default, only provides a small amount of information such as startup prompts, test completion, and final results

Level 1:adb Shell monkey-p com.shjt.map-v-V 100//provides more detailed logs, including each event information sent to the activity

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

-S (random number of seeds)

Specifies the seed value of the pseudo-random number generator, and if seed is the same, the sequence of events generated by the two monkey test 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 < ms >

Specifies the time delay between the specified user action (that is, the event), in milliseconds, and if this parameter is not specified, monkey will generate and send the message as soon as possible. Shown

Example: adb shell monkey-p com.shjt.map--throttle 3000 100

Monkey instance

Performance test of Shanghai public transport app with monkey command

adb shell monkey–p com.shjt.map–throttle 100–pct-touch 50–pct-motion 50–v–v 1000 >c:\monkey.txt

Monkey View Package Name

Install APK package name Viewer in mobile phone

Androidmanifest.xml file view under the source code

AAPT Command View

Monkey Log Analysis

Normally, if the monkey test completes successfully, at the end of the log, it prints out the current number of execution events and the time spent;//Monkey finished representative execution completed \

Unusual situation

After the monkey test error, the general analysis steps

Look at the Monkey log (note the first Swith and exception information, etc.)

1. The program is not responding to the problem: in the log search "ANR"

2. Crash problem: Search for "Exception" in the log (if null pointer appears, nullpointerexception) there must be a bug

Monkey execution interrupt, at the end of log can also see the current execution times

Must pay attention to crash

Although there are some flaws in the monkey test, we can not accurately know the recurrence steps, monkey test appears nullpointexception, are available in the user's use, when it is only a matter of time

Theoretically, all monkey crash need to be repaired before they are released.

The above is on the Android Monkey pressure test article collation, follow-up continue to add, thank you for your support!

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.