Usage of Android Monkey (i)

Source: Internet
Author: User

Monkey Introduction

Ümonkey is a command-line tool that can be run in an Android emulator or in a real device. It can send pseudo-random (pseudo-random) user event streams (such as key input, touch screen input, gesture input, etc.) to the system, which can be used for stress testing of the target application or the entire Android system. Therefore, the Monkey test is a fast and effective method to test the stability and robustness of the software.

ü Basic syntax: adb shell monkey [options] <event-count>

If you do not specify options, which is similar to using the command adb Shell Monkey 1000, then the event stream will be sent to the package installed throughout the system, in other words monkey stress tests on the entire Android system

The following is an example of a Monkey test for a specified application (third-party apps), with a number of 1000 event streams sent:

adb shell monkey-p com.alibaba.easytest 1000

1| [Email protected]:/#monkey-P com.alibaba.easytest 1000

Monkey-pcom.alibaba.easytest 1000

Activityresuming (Com.alibaba.easytest)

Activityresuming (Com.alibaba.easytest)

Activityresuming (Com.alibaba.easytest)

Activityresuming (Com.alibaba.easytest)

Events injected:1000

# # Network stats:elapsed time=40435ms (40435ms Mobile, 0ms WiFi, 0ms not connected)

Monkey Command Options

ü Get a list of options, enter the ADB shell monkey in Android 4.4, and the list of options is as follows: Use Getprop to get the version number

ü Common options and parameter description

ü- p allows you to specify multiple package names at the same time, and each package needs to be specified with the "-P" parameter. Get the package name, refer to the Python script get_package_name.py

ü -ignore-crashes ignore the application crash error, do not specify this parameter, the application appears Crash,monkey will automatically stop sending events, after specifying this parameter, monkey will also send the event after crash, know that all events sent to complete

ü -ignore-timeouts ignores errors caused by timeouts, that is, ANR errors

ü -ignore-security-exceptions Ignore permissions errors

ü -monitor-native-crashes monitoring of crash caused by C + + code

ü -ignore-native-crashes ignoring the crash caused by C + + code

ü -kill-process-after-error Kill the application process when an error occurs

ü -hprof When this option is specified, Monkey generates a performance report after the Send event is completed, and the report is generally stored in the/data/misc directory, and the analysis of the report requires the use of TraceView

ü -pct-touch Set Touch Event Scale

ü -pct-motion Set gesture event proportions, such as sliding events

ü -pct-trackball Set the ratio of tracking ball events

ü -pct-syskeys Set the ratio of system key events such as Home, back, volume +/-etc.

ü -pct-nav Set the ratio of "basic" navigation events

ü -pct-majornav Set "PRIMARY" navigation event scale

ü -pct-appswitch Set the event scale to start Activity

ü -pct-pinchzoom Set Scaling Event Scale

ü -pct-anyevent Set other event proportions

ü- s set seed number for easy reproduction of bugs

ü- v sets the verbose level of output information, 1-V for Level 1, 2-V for Level 2

ü -throttle Set the delay between events, in milliseconds

ü Number of COUNT events

End Monkey Process

In the process of executing Monkey, if you want to stop the Monkey program from running, you need to kill the Monkey process.

Use grep under Findstr,linux/mac under Üwindows

ü Execute adb shell PS |findstr Monkey

ü Run the ADB shell kill process ID after getting to the PID of the monkey process

Usage of Android Monkey (i)

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.