5th Chapter 1, "Monkeyrunner source Analysis" Monkey principle-start-up operation: Official Profile (original)

Source: Internet
Author: User

Heaven Zhuhai Branch Rudder note : Originally this series is to prepare a book, details please see the earlier blog "to seek partners to write the deep understanding of Monkeyrunner" books. But for many reasons, there is no wish. So the draft is shared here, so mistakes are unavoidable. If necessary, please refer to the following, the forwarding of the word also keep the end of each article source and other information.

In the framework of Monkeyrunner, Monkey is a service that accepts commands sent from Monkeyrunner clients and then handles each command request accordingly, so it does not operate as a tool for random stress testing. The monkey principle described in this book does not focus on its use as a stress testing tool, but rather on how it acts as a service for Monkeyrunner. I believe this is enough, because the two different modes of operation are only the source of the event, such as the direct supply of command-line parameter options when running the event source is a pseudo-random event stream from the algorithm generated by monkey itself , and the event source as the Monkeyrunner service runtime is a string Format event command sent from the network Monkeyrunner client. As long as you understand how the event source from the network is handled in monkey, you can vitalize the process from other event sources quickly and well.

In this section we first look at the official Google Monkey, so that the non-contact of the reader has a basic concept, so as to facilitate our analysis down.

Monkey is an application running on an Android target machine and is a command-line-based application interface test tool that can run independently. Based on the parameters provided by the user, it will automatically generate a pseudo-random stream of different user events based on the algorithm to drive the test, such as Click, Touch, gesture, and some system-level events, and then send these events to the Android operating system to trigger the event. Users can use monkey to perform stress tests in a random but reusable way for the application you are developing.

Monkey supports a range of parameter options to run, but the overall option is to divide the options into the following four basic categories:

    • Basic configuration Options : For example, configure the number of events that will be tested
    • Run constraint options : If you set up a single package for testing
    • event Type and frequency : for example, gesture events account for 30% of all randomly generated events, click 50%, Touch 20%
    • Debugging options

When the monkey is running, it will generate the corresponding events based on the input options and inject them into the Android operating system. At the same time, monkey also monitors the system under test and makes special treatment for the following three kinds of cases:

    • If a constraint is set and the monkey is run on one or more of the specified packages, it catches and blocks attempts to browse to other packages
    • If the application crashes or receives any unhandled exceptions, Monkey will stop running and report the appropriate error
    • If the application produces an "application not Responding" error, Monkey will stop running and report the appropriate error

Depending on the level of feedback selected by the user, the user can see the progress of the monkey execution and the progress of the event being generated.

Users can start monkey by using the command line or script on the development machine. Because monkey is running in an Android emulator/device environment, it must be started in its shell environment. You can do this by adding "adb shell" before each command, or you can enter the monkey command directly after entering the shell. The basic syntax is as follows:

If you do not specify any options, Monkey will start in silent mode and will send events to any of the apps that are already installed on the Android target machine. The following is a more typical example that launches a specified application and sends 500 pseudo-random events to it:

500

Here is a list of all the options supported by the online peer translator Monkey, and I'm not doing anything to re-create the wheels here:

Table 5-1-1 Monkey command-line options




——— to Be Continued ———

Heaven Zhuhai Branch Rudder
Public Number: Techgogogo
Weibo: Http://weibo.com/techgogogo
Csdn:http://blog.csdn.net/zhubaitian

5th Chapter 1, "Monkeyrunner source Analysis" Monkey principle-start-up operation: Official Profile (original)

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.