2. Monkey Tool for Android Auto test

Source: Internet
Author: User


Android Auto Test monkey tool


The app testing work often hears the leader say, did the app stress test do? Just into the line, do not know what is the app stress test, looking for a half day did not find what they want. After a few years, looking back to this problem, found involved in a lot of places. Below I according to own understanding to say the following two points:


    • App Run stability
    • App run stability under high-voltage server conditions





App Run stability



For example, we open the app, click on two, the app will stop running, so can you say that the app is stable? Of course, under the actual situation, will not point two down. Since point two is not going to collapse, then I will point 10,000 times, or 100,000 times? This is not a good guarantee. Of course, since we are proposing this demand, then we must



Don't be silly to use your hand to click the APP once. What's the best way to do it without a hand? Monkey is a good choice!



App run stability under high-voltage server conditions



Server high Voltage This is a precondition. We already know that the server is high voltage, then when the client sends the request, the interface or data will be garbled, etc.? Even if we are talking about monkey today, we will not talk more about it.





Monkey Tools Overview





Monkey is a command-line tool that can be run on any emulator instance or device. It sends a pseudo-random user event stream to the system as a stress test for the application software you are developing.



Monkey contains a number of options, but they are divided into four main categories:


    • Basic configuration options, such as setting the number of events to try.
    • An action constraint, such as restricting a test to a single package.
    • The event type and frequency.
    • Debugging options.





When Monkey is running, it generates events and sends them to the system. It can also monitor the system under test and find three special cases:


    • If you have restricted monkey to run in one or more specific packages, you will be monitoring the attempt to navigate to any other packages and block them.
    • If your application crashes or receives any type of unhandled exception, Monkey stops and reports an error.
    • If your application generates an application that does not respond to the error, Monkey will stop and report an error.





Personal Understanding:Monkey is of course a monkey. We mentioned a requirement above, that is, I want to verify that when I click the app 10,000 or 100,000 times, the app will run unexpectedly. Of course, these 10,000 or 100,000 times are randomly clicked. Imagine such a scene, put a keyboard in front of monkeys, monkeys will be random knocking on the keyboard? So we call any task on the random execution system called the Monkey Test. But I thought about it here, and it's not the same with monkeys turning into other animals? It is difficult to change to other animals can also play a poem not ~ ~ Haha, joking. I think it should be a combination of monkey likes to move, but two ha also like Ah ... Not tangled up.


Monkey parameter Daquan
category Options Description
So so --help Print a simple guide to use.
-v each-V on the command line will increase the verbosity level. Level 0 (the default) provides information in addition to the start notification, which is almost none outside of the test completion and the final result. Level 1 provides more detailed information about the test run, such as a single event that is sent to your activity. Level 2 provides more detailed setup information, such as selecting or not selecting an activity for testing.
Activities -s <seed> the seed value of the pseudo-random number generator. If you rerun monkey with the same seed value, it will generate the same sequence of events.
--throttle <milliseconds> inserts a fixed delay between events. You can use this option to slow down the speed of monkey. If not specified, there is no delay, and the event is generated as soon as possible.
--pct-touch <percent> adjusts the percentage of touch events. (touch events are the downstream events of a single location on the screen.) )
--pct-motion <percent> adjusts the percentage of motion events. (motion events include a downward event somewhere on the screen, a series of pseudo-random motions, and an upward event.) )
--pct-trackball <percent> adjusts the percentage of trackball events. (trackball events consist of one or more random actions, and sometimes they are clicked later.) )
--pct-nav <percent> adjusts the percentage of the basic navigation event. (navigation events are made up of up /down/left/right as input from the direction input device.) )
--pct-majornav <percent> adjusts the percentage of the primary navigation event. (These navigation events typically result in actions in the UI, such as the center button in the 5-to-keyboard, the back key, or the menu key.) )
--pct-syskeys <percent> adjusts the percentage of the System key event. (These are keys that are normally reserved for use by the system, such as Home,back,start call,end call or volume controls.) )
--pct-appswitch <percent> adjusts the percentage of activity launches. within a random interval, monkey will emit a startactivity () call as a way to maximize the coverage of all activities in the package.
--pct-anyevent <percent> adjusts the percentage of other types of events. This is the full functionality of all other types of events, such as keystrokes, other less-used buttons on the device, and so on.
Constraints -p <allowed-package-name> If you specify one or more packages in this manner, monkey will only allows the system to access activities in these packages. If your application requires access to activities in other packages (for example, selecting a contact), you will also need to specify these packages. If you do not specify any packages, monkey will allow the system to start activities in all packages. To specify multiple packages, use the-P option multiple times-one-to-p option per package.
-c <main-category> If you specify one or more categories in this manner, monkey will only allows the system to access activities listed using one of the specified categories. If you do not specify any categories, monkey will select the activities listed using the Intent.category_launcher or Intent.category_monkey category. To specify multiple categories, use the-c option multiple times-A-c option for each category.
Debugging --dbg-no-events once specified, monkey will perform the initial boot to the test activity, but will not generate any other events. for best results, combine-V, one or more package constraints, and a non-0 limit to allow monkey to run for 30 seconds or longer. This provides an environment in which you can monitor package conversions for application calls.
--hprof If set, this option generates an analysis report immediately before and after the monkey event sequence. This will generate a large (~5MB) file in Data/misc, so use it with care. for More information about trace files, see Traceview.
--ignore-crashes Typically, monkey stops when an application crashes or encounters any type of unhandled exception. If this option is specified, monkey will continue to send events to the system until the count is complete.
--ignore-timeouts Typically, monkey stops when an application encounters any type of time-out error, such as the Application Unresponsive dialog box. If this option is specified, monkey will continue to send events to the system until the count is complete.
--ignore-security-exceptions Typically, when an application encounters any type of permission error, Monkey stops, for example, if it tries to start an activity that requires certain permissions. If this option is specified, monkey will continue to send events to the system until the count is complete.
--kill-process-after-error Typically, when Monkey is stopped due to an error, the failed application remains in the running state. When this option is set, it notifies the system to stop the process where the error occurred. Note that in the case of normal (successful) completion, the initiated process does not stop, and the device is only in the final state after the final event.
--monitor-native-crashes Watch and report crashes in native code of the Android system. If--kill-process-after-error is set, the system stops.
--wait-dbg Prevents monkey from executing until the debugger connects to it.
View App Package name


Using the Package Name Viewer app, Link: https://pan.baidu.com/s/1hx5JKlUiMWuTRz9AJ9xFpA Password: d0gq





Monkey Common Command Introduction - P


Use this parameter to specify one or more packages. After the package is specified, monkey will only allow the system to launch the specified app. If you do not specify a package, Monkey will allow the system to boot all apps in the device (including the system's own features, such as phone calls, text messages, etc., which means that everything will probably be started).



Specify a package:


adb shell monkey-p xxx.xxx.xxx   //xxx.xxx.xxx as the package name, 100 times





Specify multiple packages :


adb shell monkey-p  xxx.xxx.xxx  –p  xxx.xxx.xxx  //xxx.xxx.xxx for package name, 10 times




-V


For the feedback log level, which is the degree of detail, a total of 3 levels, respectively, the corresponding parameters are shown in the following table:


// // provides a more detailed log, including each event message sent to the activity // The most detailed log, including the selected/unchecked activity information in the test




-S (random number Seed)


Used to specify the seed value of the pseudo-random number generator, and if the seed is the same, the sequence of events produced by the two monkey tests is the same. Example: Specifying a seed value of 1 with a run count of 10


Monkey test 1:adb Shell monkey-p xxx.xxx.xxx–s 1 //Specify a seed value of 1, run the number of          times toxxx.xxx.xxx–s 1      //Specify S Eed value is 1, run count is 10




--throttle


The time interval after each event-reducing the pressure on the system (if not specified, the system will send the sequence of events as soon as possible). such as:--throttle


adb shell monkey-p xxx.xxx.xxx--throttle       //specified interval is 100ms, run count is 100




--pct-touch<percent>


Specify the percentage of touch events


adb shell monkey-p xxx.xxx.xxx--pct-touch 5 //  Specify Touch event 5%, run Count




--pct-motion <percent> (sliding events)
adb shell monkey-p xxx.xxx.xxx--pct-motion 5 //  Specify a sliding event of 5% with a run count of




--pct-trackball <percent> (trackball event)
adb shell monkey-p xxx.xxx.xxx--pct-trackball 5 //  specified trackball is 5%, run Count




--pct-nav<percent> (Basic navigation event Up/down/left/right)
adb shell monkey-p xxx.xxx.xxx--pct-nav 5 //  Specify a basic navigation event of 5% with a run count of




--pct-majornav<percent> (main navigation event back key, menu key)
adb shell monkey-p xxx.xxx.xxx--pct-5 //  Specify a primary navigation event of 5% with a run count of




--pct-syskeys<percent> (System key event Home, back,Startcall, Endcall, Volumecontrol)
adb shell monkey-p xxx.xxx.xxx--pct-syskeys 5 //  Specify System key event 5%, number of runs




--ignore-crashes (ignore crashes)
adb shell monkey-p xxx.xxx.xxx--ignore-crashes //  ignore Ben collapse, run Count




--ignore-timeouts (Ignore timeout)
adb shell monkey-p xxx.xxx.xxx--ignore-timeouts //  ignore timeout, run Count




Example


1, event, interval, debug, output log integration


ADB shell monkey-p xxx.xxx.xxx-s 1--pct-touch 5--throttle--ignore-crashes--ignore-timeouts-v-V 10000 > D:\m Onkey_log.txt  





2. Stop Monkey operation


ADB shell
PS | grep Monkey

Kill 5540









Monkey Log Analysis





Log analysis, we mainly look at anomalies. Common exceptions for ANR Exception



1. Program unresponsive issue: Search the log for "ANR"
2. Crash: Search for "Exception" in the log (if a null pointer appears, NullPointerException)






As shown in the following:








Monkey Advantages and disadvantages





The advantages must be simple and easy to use ~ shortcomings, said I think there is one, such as I would like to click on a separate page of the app, for example, I just want to click the login button, then it is not good to do, but it seems to be able to write a script to solve. Studied before, to forget. After the use of the words to supplement.



2. Monkey Tool for Android Auto 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.