Android Monkey Automated Testing

Source: Internet
Author: User

Foreword If you do Android development, have not used monkey to test, then see this article today, hoping to solve some of your Android test problems. At least it will save you time for testing and find more questions.
Monkey Profile Monkey is an android command-line automated test tool that can be run in simulators and real-world devices that simulates pseudo-random user event streams, such as clicks, touches, gestures, and so on. You can use Monkey to stress test the program you are developing.
Characteristics of the Monkey:
    • The test object is the package name, specified by the-p parameter.
    • The monkey test uses an event stream, a data flow that is random, and cannot be customized.

Monkey's use of monkey is the Android system comes with, the Java language written automated testing tools, in the Android file system storage path is:/system/framework/monkey.jar
Monkey.jar program is a shell script named "Monkey" to start execution, Shell script on the Android file system storage path:/system/bin/monkey
Basic syntax
adb shell Monkey [option] <event-count>

Parameters

[Option]-P

For constraint restrictions, use this parameter to specify a package or multiple packages (the package, which is app). Once specified, monkey only allows the system to launch the specified app, and if not specified, monkey will allow the system to start all apps
[Option]-vUsed to specify the level of feedback information (the level of information is the verbosity of the log), divided into three levels, respectively, for the parameters as follows:
Log levels: Level 0
Example: adb shell monkey-p com.example.list-v 100
Description: A default value that provides only a small amount of information, such as startup hints, test completion, and final results
Log levels: Level 1
Example: adb shell monkey-p com.example.list-v-V 100
Description: Provides more detailed log information, including event information sent to activity
Log levels: Level 2
Example: adb shell monkey-p com.example.list-v-v-v 100
Description: Provides the most detailed log information, including selected and unchecked activity information in the test
[option]--kill-process-after-error
Description: Used to specify whether the current application should stop running when an error occurs. If this parameter is specified, the application stops and remains in its current state when an error occurs in the user application
[option]--throttle <milliseconds>
Description: Used to specify the interval of time for the Monkey action event, in milliseconds
<event-count>
Description: Specifies the number of random events
Example record the monkey command I used most often, which is the combination of the above parameters:
adb shell monkey-p com.example.listview-v-v-v--kill-process-after-error--throttle > 500000 . 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.