Android Monkey Automated Testing

Source: Internet
Author: User

Preface if you have not used Monkey for Android development, you can see this article today to solve some problems in your Android testing. At least it can help you save test time and discover more problems.
Monkey introduction Monkey is an Android command line automated testing tool that runs on simulators and devices. It can simulate pseudo-random user event streams, such as clicks, touch, and gestures. You can use Monkey to perform stress testing on the program being developed.
Monkey features: The test object is the package name, which is specified by the-p parameter. The event streams and data streams used for Monkey testing are random and cannot be customized.
Monkey is a built-in Android system and has an automated testing tool written in Java. The storage path of Monkey in the Android file system is/system/framework/monkey. jar.
The monkey. jar program is started and executed by a Shell script named "monkey". The storage path of the shell script in the Android file system is/system/bin/monkey.
Basic syntax

adb shell monkey [option] 
 

Parameters

[Option]-p

This parameter is used to specify one or more packages (that is, Apps ). Once specified, Monkey only allows the system to start the specified APP. If not specified, Monkey allows the system to start all apps.
[Option]-vThis parameter is used to specify the level of feedback information (the information level is the log details). It consists of three levels. The parameters are as follows:
Log Level: Level 0
Example: adb shell monkey-p com. example. list-v 100
Description: default value. Only a small amount of information such as startup prompt, test completion, and final result is provided.
Log Level: Level 1
Example: adb shell monkey-p com. example. list-v 100
Description: provides detailed log information, including event information sent to the Activity.
Log Level: Level 2
Example: adb shell monkey-p com. example. list-v 100
Note: The most detailed log information is provided, including the Activity information selected in the test and not selected.
[Option] -- kill-process-after-error
Description: it is used to specify whether to stop an error in the current application. If this parameter is specified, the application stops and remains in the current State when an error occurs in the user application.
[Option] -- throttle
Description: Specifies the interval between Monkey operation events, in milliseconds.

Description: number of random events.
Example record the monkey command that I often use, that is, the above parameters are used in combination:
Adb shell monkey-p com. example. listview-v -- kill-process-after-error -- throttle 500 500000>/mnt/sdcard/monkey. log 2> & 1 &

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.