Android Test Tutorial: Monkey command line tools

Source: Internet
Author: User
Tags command line

After finishing the application, the unit test and functional testing, it is necessary to test the impact of the application, the best way is to hire a "monkey" in the test, monkeys can blindly button, in this case, your application can still work?

The Android Test Kit provides a monkey tool that provides "monkey" functionality, but is smarter than a real monkey, and you can direct the monkey, such as the ratio of keystrokes, the frequency of an event, and so on.

A simple usage, such as your application's package name: Com.pstreets.navigator

can use adb shell monkey-p com.pstreets.navigator-v 500

Send 500 random events (including keystrokes, touch events, system events, etc.) to the application using the default configuration, which starts the corresponding activity first and then sends a random event to the application:

The Monkey tool details are as follows:

It is a command-line tool that can be run in an emulator or in an actual device. It sends a pseudo-random stream of user events to the system to perform a stress test on the application under development. Monkey includes many options, which are broadly grouped into four main categories:

· Basic configuration options, such as setting the number of events to try.

Run constraint options, such as setting to test only a single package.

Event type and frequency.

Debugging options.

When the monkey is running, it generates events and sends them to the system. At the same time, the monkey also monitors the system in the test and deals with the following three specific situations:

If Monkey is limited to running on one or several specific packages, it monitors and blocks attempts to move to another package.

If the application crashes or receives any runaway exceptions, monkey stops and complains.

If the application produces an error that the application does not respond to (application not responding), Monkey will stop and make an error.

Depending on the level of feedback you select, you can also see its execution process reports and generated events in monkey.

Basic usage of Monkey

You can start monkey by developing a command line or script on the machine. Because monkey is running in an emulator/device environment, it must be started with the shell in its environment. You can do this by adding the ADB shell before each command, or you can enter the monkey command directly after entering the shell. The basic syntax is as follows:

$ adb shell monkey [options]

If Options,monkey is not specified, it will start in no feedback mode and send the event to any package installed in the target environment. The following is a more typical command-line example, which launches the specified application and sends 500 pseudo random events to it:

$ adb shell Monkey-p your.package.name-v 500

–v

Each-V of the command line increases the level of feedback information. Level 0 (the default) provides less information in addition to startup prompts, test completion, and final results. Level 1 provides more detailed test information, such as events sent to an activity one by one. Level 2 provides more detailed setup information, such as an activity that is selected or not selected in the test.

Event

-S <seed>

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.