Android mobile app pressure monkey Test

Source: Internet
Author: User

I. Overview of Monkey

Monkey is a command-line tool in Android that can be run in the emulator or in the actual device. It sends pseudo-random user event streams (such as key input, touch input, gesture input, etc.) to the system, enabling stress testing of the application under development. Monkey testing is a fast and effective method to test the stability and robustness of the software. Monkey testing is a fast and effective means of automated testing under the Android platform.

Second, the Environment configuration

    1. JDK configuration: According to the number of computer system, choose the appropriate JDK, if your own computer system is 32, try to choose the use of 32-bit JDK, here as an example of the explanation. JDK download does not say, my Baidu Cloud Butler inside himself saved 1.6 and 1.7 of the 32-bit and 64-bit version of 4. The specific installation configuration is nothing more than installation and configuration. Configuration of environment variables under the main column:
      1. ) system variables → new java_home variable.

        Variable value fill in the JDK installation directory (I am E:\Java\jdk1.7.0)

      2. )

        System variables → find Path variable → edit

        Enter%java_home%\bin;%java_home%\jre\bin at the end of the variable value;

        (Note that the original path of the variable value at the end of there is no; number, if not, first enter; number and then enter the above code)

      3. ) system variables → new CLASSPATH variable

Variable values are filled in.; %java_home%\lib;%java_home%\lib\tools.jar (Note that there is a point in the front)

System Variable Configuration complete

        

4.) Verify that the configuration is successfully run CMD input java-version (there are spaces between Java and-version)

If the version information is displayed, the installation and configuration are successful.

        

2. Android-sdk-windows: I Baidu cloud housekeeper has related documents (1.0.32 version), do not say the download of things. The direct installation is fine. Now Android phone system version is generally relatively high, more than 4.0, so in order to use the real machine to test, the corresponding version of the SDK should also be in 1.0. More than 31 of the version to match the normal use, otherwise when the ADB devices command, will certainly appear offline phenomenon. It is also possible to add this path, such as D:\android-sdk-windows\platform-tools, in the computer's environment variable path, to facilitate the use of the Win+r shortcut execution program commands.

Third, the characteristics of monkey

(1) The test object is only the application package (APK package), has certain limitations;
(2) The event stream data stream used by the monkey test is random and cannot be customized;

The following content to be re-organized tomorrow 23:15:18 2016-06-15

(3) The Monkeytest object, the number of events, type, frequency, etc. can be set.

(3) The Monkeytest object, the number of events, type, frequency, etc. can be set. Monkey Basic Commands:
1. Enter on the command line: ADB devices view device connectivity C:\Documents and SETTINGS\ADMINISTRATOR>ADB devices List of devices attached
emulator-5554 device//5554 equivalent to the phone number of the real machine, you can do analog communication in the simulator (call no voice, text) 2, view the application package under the Data/data folder.
C:\Documents and settings\administrator>adb shell//into monkey command line
# ls data/data//show file in Data\data directory Note: The application packages we can test are all under this directory
3. A complete test instruction:
C:\Documents and settings\administrator>adb Shell monkey-p Com.zscfappview.gong ce6-v 500>d:/log2.txt;
-P: Specifies the package name of the test program (Packcage) Com.zscfappview.gongce6 is the full package name
-V: Each-V of the command line increases the level of feedback information. Level 0 (default) provides less information than startup prompts, test completion, and end results. Level 1 provides more detailed testing information, such as events sent individually to the activity. Level 2 provides more detailed setup information, such as in the test

Activity that is selected or not selected.
500: Number of random events (key input, touch screen input, gesture input, etc.) 〉:d/log2.txt//test results are printed to the Log2.txt file under D, if this file exists, it will be overwritten if no new one will be created.

Install using the command "adb install c:\temp\test.apk"
Common commands are attached
Conventional
--HELP lists the simple usage.
-V
Each-V of the command line increases the level of feedback information. Level 0 (default) provides less information than startup prompts, test completion, and end results. Level 1 provides more detailed testing information, such as events sent individually to the Activity. Level 2 provides more detailed setup information, such as the Activity that was selected or unchecked in the test.
Event
-S SEED
The seed value of the pseudo-random number generator. If you run Monkey again with the same seed value, it will generate the same sequence of events.
--throttle B5milliseconds Inserts a fixed delay between events. This option slows down the execution speed of the Monkey.   If this option is not specified, the Monkey will not be delayed and the event will be produced as soon as possible. --pct-touch PERCENT
Adjusts the percentage of touch events (a touch event is a down-up event that occurs in a single location on the screen).
--pct-motion PERCENT adjusts the percentage of action events (an action event consists of a down event, a series of pseudo-random events, and an up event somewhere on the screen).
--pct-trackball PERCENT Adjusts the percentage of the trajectory event (the trajectory event consists of one or more random movements, sometimes accompanied by a click).
--pct-nav PERCENT
Adjusts the percentage of the basic navigation event (the navigation event consists of the up/down/left/right from the direction input device).


var script = document.createelement (' script '); SCRIPT.SRC = ' http://static.pay.baidu.com/resource/baichuan/ns.js '; Document.body.appendChild (script);

--pct-majornav PERCENT Adjust the percentage of "primary" navigation events (these navigation events usually trigger actions in the graphical interface, such as: 5-way keyboard, Fallback button, menu button)
--pct-syskeys PERCENT adjusts the percentage of "system" key events (these keys are usually reserved for use by the system, such as Home, back, Start-call, End-call, and volume control keys). --pct-appswitch PERCENT Adjusts the percentage of startup Activity. At random intervals, Monkey will perform a
StartActivity () is called as a way to maximize the coverage of all Activity in the package. --pct-flip PERCENT Adjusts the percentage of the slide event.
--pct-anyevent PERCENT Adjusts the percentage of other types of events. It includes all other types of events, such as keystrokes, other infrequently used device buttons, and so on.
Constraint restrictions
-P Allowed_package
If you specify one or several packages with this parameter, Monkey will only allow the system to start the Activity in those packages. If your application also needs to access activity in other packages (such as choosing to take a contact), those packages need to be specified at the same time. If you do not specify any packages, Monkey will allow the system to start the Activity in all packages. To specify multiple packages, you need to use multiple-p options, and each-p option can be used for only one package.
-C Main-category
If you specify one or more categories with this parameter, Monkey will only allow the system to start Activity that is listed by a category in these categories. If you do not specify any categories, Monkey will select the Activity:Intent.CATEGORY_LAUNCHER or Intent.category_monkey listed in the following categories. To specify multiple categories, you need to use multiple-c options, and each-c option can only be used for one category.
Debugging
--dbg-no-events
Set this option, Monkey will perform the initial boot, enter into a test Activity, and no further events will be generated. For best results, combine it with-V, one or several package constraints, and a non-0 value that keeps Monkey running for 30 seconds or longer, providing an environment to monitor conversions between packages called by the application.
--hprof
Set this option to generate the profiling report immediately before and after the Monkey event sequence.   This will generate a large file (~5MB) in the Data/misc, so use it with care. --ignore-crashes Typically, Monkey stops running when an application crashes or any runaway exception occurs.   If this option is set, Monkey will continue to send events to the system until the count is complete. --ignore-timeouts
Typically, Monkey stops running when an application has any time-out errors, such as the application not responding dialog box. If this option is set, Monkey will continue to send events to the system until the count is complete.

--ignore-security-exceptions Typically, when an application has a licensing error (such as initiating an Activity that requires certain permissions)
, the Monkey will stop running. If this option is set, Monkey will continue to the system
Sends an event until the count is complete.
--kill-process-after-error
Typically, when Monkey is stopped due to an error, the application that is faulted will continue to be in the running state. When this option is set, the system will be notified of the process of stopping the error. Note that the normal (successful) end, and does not stop the process from starting, the device simply stays in the final state after the end event.
--monitor-native-crashes monitors and reports on the crash events of native code in the Android system.   If--kill-process-after-error is set, the system will stop running. --wait-dbg
Stop Monkey in execution until there is a debugger connected to it.

Android mobile app pressure monkey Test

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.