Monkey for Android Automated Testing

Source: Internet
Author: User
Tags benchmark netspeed

Address: http://blog.csdn.net/andy_android/article/details/7242086

 

 

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

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.

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

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.