Monkey test for Android

Source: Internet
Author: User

Monkey is a command line tool that sends a pseudo-random user event stream to the system to perform stress testing on developing applications.

Monkey usage
You can start monkey through the command line or script on the development machine.
$ 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.

Monkey includes many options

-- V
Each-V in the command line will increase the level of feedback information. Level 0 (default) provides less information except the startup prompt, test completion, and final result. Level 1 provides detailed test information, such as events sent to the activity one by one. Level 2 provides more detailed settings, such as the selected or unselected activity in the test.

-S <seed>
The seed value of the pseudo-random number generator. If you run the monkey again with the same seed value, it generates the same event sequence.

-- Throttle <milliseconds>
Insert a fixed delay between events. This option can reduce the execution speed of monkey. If this option is not specified, the monkey will not be delayed and the event will be generated as quickly as possible.

-- PCT-touch <percent>

Adjust the percentage of touch events (a touch event is a down-up event that occurs at a single location on the screen ).

-- PCT-motion <percent>
Adjust the percentage of Action events (Action events are composed of a down event, a series of pseudo-random events, and an up event somewhere on the screen ).

-- PCT-trackball <percent>
Adjust the percentage of track events (track events consist of one or more random moves, sometimes with clicks ).

-- PCT-nav <percent>
Adjust the percentage of "Basic" navigation events (a navigation event consists of up/down/left/right from the input device ).

-- PCT-majornav <percent>
Adjust the percentage of "Main" navigation events (these events usually lead to operations in the graphic interface, such as the intermediate buttons of the 5-way keyboard, the back button, and the menu button)

-- PCT-syskeys <percent>
Adjust the percentage of system key events (these keys are usually retained and used by the system, such as home, back, start call, end call, and volume control keys ).

-- PCT-Modify witch <percent>

Adjust the percentage of started activity. During the random interval, monkey will execute a startactivity () call as a method to overwrite all the activities in the package to the maximum extent.

-- PCT-anyevent <percent>
Adjust the percentage of other types of events. It includes all other types of events, such as buttons, other infrequently used device buttons, and so on.

-P <allowed-package-Name>
If you use this parameter to specify one or more packages, Monkey only allows the system to start the activity in these packages. If your application needs to access the activity in other packages (for example, select a contact), the packages also need to be specified here. If no package is specified, monkey allows the system to start the activity in all the packages. To specify multiple packages, you need to use multiple-P options. Each-P option can only be used for one package.

-C <main-Category>
If this parameter is used to specify one or more categories, monkey allows the system to start only the activities listed by a category in these categories. If no category is specified, monkey selects the activity listed in the following categories: intent. category_launcher or intent. category_monkey. To specify multiple categories, you need to use multiple-C options. Each-C option can only be used for one category.

Debugging
-- Dbg-no-Events

When this option is set, monkey will start initially, enter a test activity, and no further event will be generated. In order to get the best result, it is combined with-V, one or more package constraints, and a non-zero value that keeps the monkey running for 30 seconds or longer to provide an environment, monitors the conversion between packages called by applications.

-- Hprof
Set this option to generate a profiling report immediately before and after the monkey event sequence. This will generate a large file (~ 5 MB), so use it with caution.

-- Ignore-crashes
In general, monkey stops running when the application crashes or any runaway exception occurs. If this option is set, monkey continues to send events to the system until the count is complete.

-- Ignore-timeouts
Generally, when an application encounters any timeout error (such as the "Application not responding" dialog box), the monkey stops running. If this option is set, monkey continues to send events to the system until the count is complete.

-- Ignore-security-Exceptions
In general, when an application has a license error (such as starting an activity that requires certain licenses), the monkey stops running. If this option is set, monkey continues to send events to the system until the count is complete.

-- Kill-process-after-Error
Generally, when a monkey stops due to an error, the failed application continues to run. When this option is set, the system will be notified to stop the process with an error. Note that the process ends normally (successfully) and does not stop. The device simply remains in the final state after the event ends.

-- Monitor-native-crashes
Monitors and reports crash events of local code in the Android system. If -- kill-process-after-error is set, the system stops running.

-- Wait-dbg
Stop the running monkey until a debugger is connected to it.

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

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

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

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

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.