Monkeyrunner Automation Test (i)

Source: Internet
Author: User

The current Android SDK comes with a ready-made test tool with Monkey and Monkeyrunner two. We don't look like these two names, but they are totally different two tools that are used in different areas of testing. In general, Monkey is mainly used in stress and reliability testing, running the command can randomly send a variety of simulation keyboard event flow to the target program, and can define the number of times sent, in order to observe the application of the stability and reliability of the test, the application is relatively simple, remember that a few commands on the line. And Monkeyrunner, in contrast, will be a bit more powerful, it can be applied to functional testing, regression testing, and can customize the test extension, flexibility, and testers can fully control.

This is my study monkeyrunner when the notes, to view the network of information and testing by myself, because I just contact, so this content is superficial

Please build your own Android environment when testing the following examples.

First, open the device you want to test

Before using the Monkeyrunner test must open the corresponding simulator, the use of mobile phone testing friends will needless to say, as long as the phone has been connected to the good, then the use of the simulator's friends attention, here to focus on the use of simulator testing, How to open the simulator: (1) using Eclipse to open the Android emulator directly, this does not have to say (2) then the main point is to open the emulator with the cmd command line: Command EMULATOR-AVD Test (test is the name of the emulator)


Command line,


In general this case proves that the simulator has been opened, it is important to note that you must be accurate to the tools folder of your SDK, my SDK folder is:

D:\software\SDK\tools

If there is an error in execution


The reason is that your environment variable is missing a configuration. Add "Android_sdk_home" to "System variables" and set its value to "D:\software\SDK" (of course, the variable value here is also the total path of your SDK), as shown in:


When you are sure, close the cmd window and reopen cmd. Execute the above command. The emulator will be enabled.

After the simulator starts successfully, we still operate in the CMD environment, and then open a cmd, navigate to the Tools folder under the SDK, enter Monkeyrunner to start the automated test,


This proves that you have entered the Monkeyrunner command mode and entered

From Com.android.monkeyrunner Monkeyrunner,monkeydevice


then enter Device=monkeyrunner.waitforconnection () so that the Monkeyrunner has a test machine connected,


Then, you can install the application to the test machine.

Input: Device.installpackage ("d:/gyp/2016_6_13_gaoyipin_4.5.4.1/gaoyipin/bin/splashactivity.apk") can be installed successfully,


Note that the partition under the drive letter or folder must use "/" instead of "\", and if "\" is used, the installation will fail.


Once the installation is successful, you can start any activity.

Input command: device.startactivity (component= "com.breaker.hp/com.czh.gaoyipinapp.slashscreen.splashactivity")


Be sure to note that if it is copied over must not forget the last "), if you forget it will report this error


After component is the package name + class name, be sure to pay attention to your package name and class name



I found here in the manifest file, if your package name and the class name is not correct, will not give you an error, just can't open the activity you are opening, I also struggled here for a long time, finally found in the manifest file package name, but it is a waste


Because, there is no error, so do not know exactly where the problem, now think back, that period of time, really feel that the whole person is not good.

Monkeyrunner Automation Test (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.