Monkey test for Android

Source: Internet
Author: User

The android debugging bridge (ADB) shell in the android SDK contains a tool for testing --Monkey.I do not know the origins of the earliest monkey name, but he is indeed like a naughty monkey, In the Android app, all kinds of chaos, chaos, and touch.

How to Use: Enter the command line, go to the platform-tools directory of the android SDK, and enter the command

User @ User :~ /Workspace/android-sdk-linux_x86/platform-tools $ ADB shell monkey

You can see the usage of the configuration parameters of the monkey tool. As follows:

Usage: Monkey [-P allowed_package [-P allowed_package]...]
[-C main_category [-C main_category]...]
[-- Ignore-Crashes] [-- ignore-timeouts]
[-- Ignore-security-exceptions]
[-- Monitor-native-Crashes] [-- ignore-native-crashes]
[-- Kill-process-after-Error] [-- hprof]
[-- PCT-touch percent] [-- PCT-motion percent]
[-- PCT-trackball percent] [-- PCT-syskeys percent]
[-- PCT-nav percent] [-- PCT-majornav percent]
[-- PCT-Reset witch percent] [-- PCT-flip percent]
[-- PCT-anyevent percent]
[-- PKG-blacklist-file package_blacklist_file]
[-- PKG-whitelist-file package_whitelist_file]
[-- Wait-dbg] [-- dbg-no-events]
[-- Setup scriptfile] [-F scriptfile [-F scriptfile]...]
[-- Port port]
[-S seed] [-V [-v]...]
[-- Throttle millisec] [-- randomize-Throttle]
Count

You can enter


User @ User :~ /Workspaces/android-sdk-linux_x86/platform-tools $ ADB Shell

In this way, you enter the ADB shell, and you can directly enter the monkey to execute the command. Otherwise, you must enter ADB shell monkey for each operation.


Practice

1. Just for fun

The simplest way to start is:

ADB shell monkey-P com. Snake-V 100

Indicates that the app of the package after-P is tested for 100 times completely random. Monkey generates a random event of 100 times.

The output lists the generated random events in sequence.

2. Targeted Testing

Of course, there is no need for apps to have different focuses, and we need to focus on different tests. At this time, we may need to adjust the proportions of different events in random events.

-- PCT is the use. For example, "-- PCT-touch 50%" indicates that 50% of the stochastic events are generated, while "-- PCT-syskeys 10%" indicates that 10% of the key events are generated.

3. debugging Analysis

As the test goes deeper, we need to ignore the app crash, instead of stopping. monkey can do the same.

-- Ignore-crashes

It can even generate a profiling report!

-- Hprof

For more debugging functions, see the following table.

This table provides a clear and informative description of monkey usage.

Related Article

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.