Android App Stress Test (i) Monkey tool introduction

Source: Internet
Author: User

Android App Stress Test (i) Monkey tool introduction

Objective

This article mainly introduces monkey tools. Monkey testing is an automated test of the Android platform, through the monkey program to simulate the user touch screen, swipe, button and other operations to stress the program on the device, the detection of how long the program will be abnormal. This article is mainly for their own reference.

Directory

1, Monkey Introduction

2. Monkey parameter description

3. Monkey instances

4, Monkey test results analysis

1, Monkey Introduction
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 user event stream (such as key input, touch screen input, gesture input, etc.) to the system to perform stress testing on the app. Monkey testing is a fast and effective method to test the stability and robustness of the software.

2. Monkey parameter description

Monkey includes many options, broadly divided into four categories:

1. Basic Options --help: Print help Information-V: Specifies the level of detail for printing information, and one-V adds a level.

Log level 0, default, provides only a small amount of information, such as startup hints, test completion, and final results

Log Level 1, which provides a more detailed log, including each event message sent to activity

log Levels Level 2, the most detailed logs, including the selected/unchecked activity information in the test

2. The seed value of the event option -S pseudo-random number generator. If you run monkey again with the same seed value, it will generate the same sequence of events. --throttle < milliseconds > inserts a fixed delay between events. This option slows down the execution speed of the monkey. If this option is not specified, the monkey will not be delayed and the event will be produced as soon as possible. --pct-touch adjusts the percentage of touch events (a touch event is a down-up event that occurs in a single location on the screen). --pct-motion adjusts the percentage of action events (an action event consists of a down event, a series of pseudo-random events, and an up event somewhere on the screen). --pct-trackball adjusts the percentage of the trajectory event (the trajectory event consists of one or more random movements, sometimes accompanied by a click). --pct-nav adjusts the percentage of the basic navigation event (the navigation event consists of the up/down/left/right from the direction input device). --pct-majornav Adjust the percentage of "primary" navigation events (these navigation events typically cause actions in the graphical interface, such as the 5-way Keyboard's middle button, fallback button, menu key)--pct-syskeys Adjust the percentage of the System key event (these keys are usually retained , which is used by the system, such as home, back, Start-call, End-call, and volume control keys. --pct-appswitch Adjust the percentage of startup activity. In a random interval, monkey executes a startactivity () call as a way to maximally cover all activity in the package. --pct-anyevent adjusts the percentage of other types of events. It includes all other types of events, such as keystrokes, other infrequently used device buttons, and so on. 3. constraint option -P If you specify one or several packages with this parameter, monkey will only allow the system to start the activity in those packages. If your application also needs to access activity in other packages (such as choosing to take a contact), those packages need to be specified at the same time. If you do not specify any packages, monkey will allow the system to start the activity in all packages. To specify multiple packages, you need to use multiple-p options, and each-p option can be used for only one package. -C If you specify one or more categories with this parameter, monkey will only allow the system to start activity that is listed by a category in these categories. If you do not specify any categories, MONKEY will select the Activity:Intent.CATEGORY_LAUNCHER or Intent.category_monkey listed in the following categories. To specify multiple categories, you need to use multiple-c options, and each-c option can only be used for one category.

--dbg-no-events set this option, monkey will perform the initial boot, Enters a test activity, and then no further events are generated. For best results, combine it with-V, one or several package constraints, and a non-0 value that keeps monkey running for 30 seconds or longer, providing an environment to monitor conversions between packages called by the application. --hprof set this option to generate the profiling report immediately before and after the monkey event sequence. This will generate a large file (~5MB) in the Data/misc, so use it with care. --ignore-crashes Typically, monkey stops running when an application crashes or any runaway exception occurs. If this option is set, Monkey will continue to send events to the system until the count is complete. --ignore-timeouts Typically, monkey stops running when an application has any time-out errors, such as the application not responding dialog box. If this option is set, Monkey will continue to send events to the system until the count is complete. --ignore-security-exceptions Typically, when an application has a licensing error (such as initiating an activity that requires some permission), Monkey will stop running. If this option is set, Monkey will continue to send events to the system until the count is complete. --kill-process-after-error Typically, when Monkey is stopped due to an error, the application that is faulted continues to be in the running state. When this option is set, the system will be notified of the process of stopping the error. Note that the normal (successful) end, and does not stop the process from starting, the device simply stays in the final state after the end event. --monitor-native-crashes monitors and reports on the crash events of native code in the Android system. If--kill-process-after-error is set, the system will stop running. --wait-dbg stops executing the monkey in the execution until there is a debugger connected to it.

Reference: https://developer.android.com/intl/zh-cn/tools/help/monkey.html

 

3. Monkey instances
1), specify a package: adb ShellMonkey-p Com.example.findyou 10
2), specify multiple packages: adb ShellMonkey-p com.example.findyou–p com.example.findyou1-p COM.EXAMPLE.FINDYOU2 100
3), seed value: Monkey Test 1:adb ShellMonkey-p Com.example.findyou–s 10 100
Monkey Test 2:ADB ShellMonkey-p Com.example.findyou–s 10 100
Specifying the same seed value guarantees that the random sequence of operations produced by the two Tests is exactly the same
4), log level
Level 1:ADB ShellMonkey-p COM.EXAMPLE.FINDYOU–V-V 100
Description provides a more detailed log, including each event message sent to the activity
Level 2:ADB ShellMonkey-p Com.example.findyou–v-v–v 100
Description of the most detailed log, including the selected/unchecked activity information in the test

  

4, Monkey test results analysis
Monkey Test og Analysis, we can use a few key words to determine whether the test passed.

1) Monkey finished open log to see the bottom of log, if there is a field similar to the following : # Network stats:elapsed time =5123ms (5123ms Mobile, 0ms WiFi, 0ms not connected)
Monkey finished This field indicates that the Monkey of this time is no exception and the test passes.

2) CRASH

Similarly, after getting the log, search for the "CRASH" field, if the search results, it indicates that there is a problem with the process, the test does not pass. CRASH:com.onekchi.downloadmanager (PID 12919)

3) ANR searches the log for this field, and if there is a search result, it means that the test object appears unresponsive during the test, so the test does not pass. --throttle < milliseconds > value recommended for

4) Unable to search for the above information this situation is generally caused by external reasons rather than the program itself. For example, the computer abnormal test interrupted, need to re-test.

Android App Stress Test (i) Monkey tool introduction

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.