[Android] Automatic Test Tool Monkey

Source: Internet
Author: User

Preface:

Recently, I started to study Android automated testing methods, and made some simple arrangements for some of the tools, methods, and frameworks, this includes the android testing framework, CTS, Monkey, Monkeyrunner, benchmark, and other test tools. Due to the short contact time and shortcomings in many places, I hope to have more exchanges with you.
 

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 a pseudo-random user event stream (such as key input, touch screen input, and gesture input) to the system to perform stress testing on the application being developed. 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]

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 500 pseudo-random events to it:

$ Adb shell monkey-p your. package. name-v 500
 

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

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. providers. media

Com. android. settings

Jp. co. omronsoft. openwnn

Com. android. providers. userdictionary

Com. android. quicksearchbox

Com. android. protips

Com. android. browser

Com. android. launcher

Com. android. term

Com. android. speechrecorder

Com. android. server. vpn

Com. android. defcontainer

Com. svox. pico

Com. android. customlocale

Com. android. development

Com. android. soundrecorder

Com. android. providers. drm

Com. android. spare_parts

Com. android. providers. downloads. ui

Com. android. fallback

Com. android. providers. applications

Com. android. netspeed

Com. android. wallpaper. livepicker

Android. tts

Com.android.html viewer

Com. android. music

Com. android. certinstaller

Com. android. inputmethod. pinyin

Com. android. providers. subscribedfeeds

Com. android. inputmethod. latin

Com. android. gallery

Com. android. systemui

Com. android. contacts

Com. android. phone

Com. android. sdksetup

Com. android. calculator2

Com. android. packageinstaller

Com. android. camera

Com. android. providers. settings

Com. thestore. main

Com. android. providers. contacts

5. Use com. android. calculator2 as the object to perform MonkeyTest.

# Monkey-p com. android. calculator2-v 500

-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. 

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.