Android automated testing tool-monkey

Source: Internet
Author: User

Preface:

Recently, I started to study Android automated testing methods,SortedSome tools, methods, and frameworks, including the android testing framework, CTS, monkey, monkeyrunner, benchmark, and other test tools.
 

1. What is monkey?

Monkey is a command line tool in Android and can be run in a simulator or on a real device. It sends pseudo-random user event streams (such as key input, touch screen input, and gesture input) to the system to realize the application under development.ProgramPerform stress testing.

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

Ii. Monkey features

1. The test object is only an application package and has certain limitations.

2. The event stream data stream used for monky testing is random and cannot be customized.

3. You can set the monkeytest object, event quantity, type, and frequency.
 

III. Basic usage of monkey

The basic syntax is as follows:

$ ADB shell monkey [Options]

Options(ADB-D shell monkey ):

Usage: Monkey [-P allowed_package [-P allowed_package]...] <br/> [-C main_category [-C main_category]...] <br/> [-- ignore-Crashes] [-- ignore-timeouts] <br/> [-- ignore-security-exceptions] <br/> [-- Monitor-native-crashes] [-- ignore-native-Crashes] <br/> [-- kill-process-after-Error] [-- hprof] <br/> [-- PCT-touch percent] [-- pct -Motion percent] <br/> [-- PCT-trackball percent] [-- PCT-syskeys percent] <br/> [-- PCT-nav percent] [-- PCT-majornav percent] <br/> [-- PCT-wide witch percent] [-- PCT-flip percent] <br/> [-- PCT-anyevent percent] <br/> [-- PKG-blacklist-File package_blacklist_file] <br/> [-- PKG-whitelist-file package_whitelist_file] <br/> [-- Wait-dbg] [-- dbg-no-events] <br/> [-- Setup scriptfile] [-F scriptfile [-F scriptfile]...] <br/> [-- Port port] <br/> [-s seed] [-V [-v]...] <br/> [-- throttle millisec] [-- randomize-Throttle] <br/> count <br/>

If no options is specified, monkey starts in non-feedback mode and sends any event to all packages installed in the target environment. The following is a more typical command line example. It starts a specified application and sends 9999 pseudo-random events to it:

$ ADB shell monkey-p your. Package. Name-V 9999
 

4. One monkey test instance

Through this example, we can understand the monkey test steps and how to know which applications can be tested with monkey.

In Windows (Note: Step 2-4 is to check which application packages can be tested, which can be omitted ):

1. Start an android emulator through eclipse

2. Enter ADB devices in the command line to view the device connection status.

C: \ Documents ents and Settings \ Administrator>ADB Devices

List of devices attached

Emulator-5554 Device

Emulator-5556 Device

015ed9a50c00a01a Device

3. If a device is connected, enter ADB shell in the command line to enter the Shell Interface.

C: \ Documents ents and Settings \ Administrator>ADB Shell

4. view the application packages in the data/data folder. Note: All the application packages we can test are in this directory.

C: \ Documents ents and Settings \ Administrator> ADB Shell

#Ls data/Data

Ls data/Data

Com. Google. Android. btrouter

Com. Android. providers. Telephony

Com. Android. MMS

Com. Android. providers. downloads

Com. Android. Alibaba clock

Com. Android. Email

Com. Android. Browser

Com. Android. calculator2

....

5. Use com. Android. calculator2 as the object to perform monkeytest.

# Monkey-P com. Android. calculator2-V 9999

Where:

-P indicates the object package.

-V indicates the number of events.

During the running process, the applications in the emulator are constantly switching the screen.

Based on the selected feedback information of different levels, you can also see the execution process report and generated events in the monkey.

Note: For specific parameter settings, refer:

Http://developer.android.com/guide/developing/tools/monkey.html

5. Stop conditions for monkey testing

Monkey test is automatically stopped in the following three conditions during execution:

1. If the monkey is limited to one or more specific packages, it will monitor and block operations that attempt to switch to other packages.

2. If the application crashes or receives any exceptions that are out of control, the monkey stops and reports an error.

3. If the application generates an application not responding error, the monkey will stop and report an error.

It is considered a stable program after multiple monkey tests with different settings.


Reference recommendations:

Monkey test Overview [Example]

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.