In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to use Monkey tools, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.
Today I'm going to talk about a recently used tool-monkey. As defined on the Api website, Monkey is a program that runs on a simulator or device that generates a pseudo-random stream of user events (such as clicks, touches or gestures, as well as many system-level events). You can use Monkey to stress test the application you are developing in a random and repeatable manner. To put it bluntly, Monkey can simulate the response of a user or system. Conduct stress testing during development.
1. Introduction of Monkey tools.
Monkey is a command-line tool that can run on any simulator or device that sends pseudo-random streams of user events to the system. Implement stress testing of the application under development.
Monkey includes many operations, but it is generally classified into the following four categories:
A: basic configuration options, such as setting the number of events.
B: restrictions on operations, such as restrictions that operate only in this single package.
C: event type and frequency.
D: debug option.
When Monkey is running, it generates and sends events to the system, and listens to the system for special handling if the following three situations occur in the test environment:
If you specify that Monkey runs in one or more specific packages, it will try to block other packages at the same time.
2 if the application you are testing crashes or encounters an exception that cannot be caught, Monkey will stop and report an error.
3 if your application appears ANR,Monkey will also stop and report an error.
Depending on the Verbosity-level Log you choose, you can see the process logging that Monkey is running.
2. Basic usage
You can run Monkey from the command line or scripting language in the development environment. Because Monkey runs on an emulator or device, the command line must have an shell environment. You can run commands on adb shell. You can also enter the command line operation of Monkey.
The basic syntax is as follows:
$adb shell monkey [options]
If there is no [options], Monkey runs in silent mode (there are no verbose-level logs) and sends events (commands) to all packets on the device.
$adb shell monkey-p your.package.name-v 500
The above command sends 500 pseudo-random events to the application.
The command line in the Api document is explained in detail as follows:
Some of the command parameters in the above api document can be viewed and used through-- help.
such as
> adb shell monkey-p com.ydzy.ydzydemo-v-v-v 10-script-ignore-crashes-hprof > output.txt
The above command roughly means to simulate pseudo-random events 10 times, and those who ignore the meaning of crashes,-hprof will generate an analysis report according to the previous event sequence, and the file size is about 5MB. This should be the same as the file generated by the TraceView tool. > output.txt
This command means to output db shell monkey-p com.ydzy.ydzydemo-v-v-v 10-script-ignore-crashes-hprof to the output.txt file. The generated output.txt can be found in the following figure:
3. Analysis of test results
Because if you simulate too many times, a large number of files will be generated, and all the pseudorandom numbers above me are set to 10. Here is the content of the output.txt file:
(blue is the journal.-Red represents my comments.)
: Monkey: seed=0 count=10 (seed is the parameter detailed on the command line in the second part above, which represents the pseudo-random value generator, which represents the same random value that has been run many times, and the same count represents the number of simulated test pseudo events.)
: AllowPackage: com.ydzy.ydzydemo
: IncludeCategory: android.intent.category.LAUNCHER
: IncludeCategory: android.intent.category.MONKEY
/ / Event percentages: (pseudo event classification (representing the proportion of time taken up by touch type, motion, trackball, syskeys, nav, majornav, appswitch, flip, anyevent, respectively)
/ / 0: 15.0%
/ / 1: 10.0%
/ / 2: 15.0%
/ / 3: 25.0%
/ / 4: 15.0%
/ / 5: 2.0%
/ / 6: 2.0%
/ / 7: 1.0%
/ / 8: 15.0%
: Switch: # Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=com.ydzy.ydzydemo/com.ydzy.musicbook.ui.HomeActivity;end (means to jump to HomeActivity)
/ / Allowing start of Intent {act=android.intent.action.MAIN (allows to jump in the package) cat= [android.intent.category.LAUNCHER] cmp=com.ydzy.ydzydemo/com.ydzy.musicbook.ui.HomeActivity} in package com.ydzy.ydzydemo
Events injected: 10 (event injection)
: Dropped: keys=0 pointers=0 trackballs=0 flips=0 (discarded event record)
# # Network stats: elapsed time=42ms (0ms mobile, 42ms wifi, 0ms not connected) (statistical cost event status 42 milliseconds wifi 0 milliseconds and the network is always connected)
/ / Monkey finished (test completed, if there is an exception, if crashes is not ignored, it will stop and an exception will be displayed)
If crashes is dropped, there should be a field like CRASH.
About how to use Monkey tools to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.