Android Automated test tool--monkey introduction and Getting Started

Source: Internet
Author: User

Remember the second unit of the Android development in the monkey for a few hours before the launch, indeed can also find some problems, the crash rate is low, not measured can really press a pressure to search the next information, Monkey is really simple, found the problem of their own search is what the problem, do not find anything on the run to ask the development

The following is an introduction to the principle of Monkey Monkey is a command-line tool in Android that can be run in the emulator or the actual device. It sends pseudo-random user event streams (such as key input, touch input, gesture input, etc.) to the system, enabling stress testing of the application under development. Monkey testing is a fast and effective method to test the stability and robustness of the software.

Monkey test, all events are randomly generated, without any subjectivity of the person.

Using the monkey process

In general, it is relatively simple to test with monkey, but it is necessary to do some more complex preparation work. The following is a detailed test procedure (very simple OH), the content is based on the already configured ADB environment (if this part is not clear, please first configure the environment, this does not describe).

1, ADB connected to Android test equipment.

The author uses a virtual machine, cmd ADB devices view device connection situation

C:\Documents and SETTINGS\ADMINISTRATOR>ADB devices List of devices attached emulator-5554 device

2. Determine the PackageName of the application you want to test.

In the case of a device connection, enter on the command line: adb shell enters the shell interface

C:\Documents and settings\administrator>adb Shell

#

View the application package under the Data/data folder. Note: The application packages that we can test are all under this directory

C:\Documents and settings\administrator>adb Shell

# ls data/data ls command means to display the file under the directory

LS Data/data

Com.google.android.btrouter

Com.android.providers.telephony

Com.android.mms

Com.android.providers.downloads

...

With Com.android.calculator2

Com.thestore.main

Com.android.providers.contacts

3, with Com.android.calculator2 as the object of the Monkeytest Android computer program

#monkey-P com.android.calculator2-v 500 about the parameters, let's introduce the basic

-P indicates that the object package –v represents the feedback information level

4. Stop conditions for the monkey test

Monkey test will automatically stop in the following three scenarios during execution:

1. If monkey is qualified to run on one or several specific packages, it will monitor and block attempts to move to other packages.

2. If the application crashes or receives any runaway anomalies, the monkey will stop and error.

3. If the application produces an error that the application does not respond (application not responding), the monkey will stop and make a mistake.

It is a stable enough program to pass multiple and different sets of monkey tests.

5. Parameter Introduction

Category Option Describe
General
Conventional
--help Lists the simple usage.
-V Each-V of the command line increases the level of feedback information. Level 0 (default) provides less information than startup prompts, test completion, and end results. Level 1 provides more detailed testing information, such as events sent individually to the activity. Level 2 provides more detailed setup information, such as the activity that was selected or unchecked in the test.
Events
Event
-S <seed> The seed value of the 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 <percent> Adjust percentage of touch events. (Touch events is a down-up event in a and the screen.)
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 <percent> 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 <percent> Adjusts the percentage of track events (the trajectory event consists of one or more random movements, sometimes accompanied by clicks).
--pct-nav <percent> 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 <percent> Adjust the percentage of primary navigation events (these navigation events usually trigger actions in the graphical interface, such as: 5-way keyboard, Fallback button, menu button)
--pct-syskeys <percent> Adjusts the percentage of the System key event (these keys are usually reserved for use by the system, such as home, back, Start call, End call, and volume control keys).
--pct-appswitch <percent> Adjusts 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 <percent> 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.
Constraints
Constraint restrictions
-P <allowed-package-name> 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.

According to the way you want to set their own parameters, if the error attempt to analyze their own, and then the wrong positioning, of course, can not locate the Android development to help see.

Android Automated test tool--monkey introduction and Getting Started

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.