Android automated testing using ADT's own tools (i)

Source: Internet
Author: User

We may need some tool support when we start the automated tests. For the Android platform, the official has integrated several tools that can be used for automated testing in the developer tools ADT. If you use these tools, you may not need to download additional tools to start your own automated tests (the Java environment is necessary for the normal use of ADT, of course). This series of articles will be a brief introduction to these tools, respectively.

The tools integrated in ADT that can be used for automated testing include:

    • Monkey
    • Monkeyrunner
    • Uiautomator (Android 4.0 + system only)

The most common use scenario for Monkey is to perform a completely random test, using monkey alone, and you can't follow a given step.

Monkey need to use USB to connect the device to the PC, on the PC side using adb shell command to invoke the device side of the Monkey program, the device side of the monkey program to generate a random sequence of operations to execute.

Monkeyrunner also communicates via USB to the monkey program running on the device side, but Monkeyrunner sends the specified instructions directly, which also supports scripting, unified operation,

So Monkeyrunner can do some functional tests and regression tests.

Uiautomator can complete a number of more complex functional and regression tests, and the tool uses Java to write test apk installation to run on the device, and we'll cover the uiautomator in more detail in a future article.

In addition, ADT also has instrument for white-box testing, which can actually be used for automated testing, and some third-party automated testing tools use instrument, such as rubotium and Calabash

Examples of usages of monkey

Monkey is a fast and effective tool for testing the stability and robustness of applications, which is actually a simple and rough stress test.

Its basic function is to send random user events (such as screen clicks, drag, and system keystrokes) to the app being tested.

Enter the command on the Windows command line adb Shell Monkey + a number to start the monkey test, this input number is the maximum number of actions to perform.

Actual use can take advantage of the parameter-p limit operation in effect of the application, the various operations outside the application will not take effect, which avoids the testing of some of the wrong operation. Like what:

ADB shell Monkey-p sogou.mobile.explorer 60000

By default monkey will automatically stop if it encounters a crash of the app under test, and the crash information can be monkey collected and printed to the command line if you want to use monkey to discover the crash that was affected by the test.

You may need to save the monkey run results to a file

ADB shell monkey-p sogou.mobile.explorer-v 60000 > 1.txt

With this batch command, you can keep monkey running and keep the crash information you've collected as close to different files as possible:

Monkey does not directly define what each step is, but the percentage of each type of operation can be configured through the parameters of the runtime.

Using monkey may find some application crashes caused by certain operations, but this blind random test is inefficient.

We still want to be able to define the automation we want to do ourselves, which can be done with Monkeyrunner.

The next article in this series will show you how Monkeyrunner functions and how to use them.

reprint Please specify: Http://blog.csdn.net/sogouauto

Android automated testing using ADT's own tools (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.