Android Monkey Stress Test Introduction
Monkey is a command-line tool provided by the Android SDK that can be easily and easily run on any version of the Android emulator and physical device. Monkey will send a pseudo-random user event stream for stress testing of the app
Read Catalogue
- Environment construction
- What is Monkey
- What Monkey to do
- Monkey Program Introduction
- Monkey Architecture
- Monkey weaknesses
- Monkey parameter Daquan
- Monkey Command Basic Parameters Introduction
- Monkey instances
- Monkey View Package Name
- Monkey Log Analysis
- Must pay attention to crash
Environment construction
Install the Android SDK and configure environment variables
Http://pan.baidu.com/s/1jIlifbS
What is Monkey
As the name implies, Monkey is a monkey, monkey test, like a monkey, in front of the computer, random knocking on the keyboard in the test. The monkey doesn't know anything, only knows how to knock.
Through the monkey program to simulate the user touch screen, sliding trackball, keystrokes and other operations to test the program on the device stress testing, how long the time of the test will occur abnormal
What Monkey to do
Monkey is a stress test gadget used primarily for Android stress testing, the main purpose of which is to test whether the app will crash.
Monkey Program Introduction
(1) Monkey program by the Android system, using the Java astonished words written, in the Android file system storage path is:/system/framework/monkey.jar;
(2) Monkey.jar program is a shell script named "Monkey" to start execution, shell script in the Android file system storage path is:/system/bin/monkey;
(3) Monkey command start mode:
A) The monkey test can be performed via the PC cmd window: adb shell Monkey {+ Command arguments}
b) The ADB shell enters the Android system on the PC and performs the monkey test by executing the monkey {+ Command parameter}
c) Execute the Monkey command directly on the Android or emulator to install the Android terminal emulator on the Android machine
Monkey Architecture
The Monkey runs on the device or emulator and can be run off the PC (the common practice is to use Monkey as a test tool for sending random key messages like the application under test. Verify that the application under test will flash or crash in the presence of these random inputs
Monkey weaknesses
Monkey Although it is possible to send a keystroke message based on a specified command script, it does not support conditional judgment, nor does it support reading information from the interface under test to perform validation operations.
Monkey parameter Daquan
Monkey Command Basic Parameters Introduction
-p < allowable list of package names >
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.
Specify a package: adb shell monkey-p com.shjt.map 100
Specify multiple packages: adb shell monkey-p fishjoy.control.menu–p com.shjt.map 100
-V
To specify the level of feedback information (the level of information is the verbosity of the log), a total of 3 levels, respectively, the corresponding parameters are shown in the following table:
Level 0:adb Shell monkey-p com.shjt.map-v 100//default, provides only a small amount of information such as startup hints, test completion, and final results
Level 1:adb Shell monkey-p com.shjt.map-v-V 100//provides more detailed logs, including each event message sent to activity
Level 2:adb Shell monkey-p com.shjt.map-v-v-v 100//The most detailed log, including the selected/unchecked activity information in the test
-S (random number Seed)
Specifies the seed value of the pseudo-random number generator, and if seed is the same, the sequence of events produced by the two monkey tests is the same. Example:
Monkey test 1:adb Shell monkey-p com.shjt.map–s 10 100
Monkey test 2:adb Shell monkey-p com.shjt.map–s 10 100
--throttle < milliseconds >
Specifies the delay between user actions (that is, events), in milliseconds, and monkey generates and sends messages as quickly as possible if this parameter is not specified. Shown
Example: adb shell monkey-p com.shjt.map--throttle 3000 100
Monkey instances
Performance test of Shanghai bus app with monkey command
adb shell monkey –p com.shjt.map –-throttle 100 –-pct-touch 50 –-pct-motion 50 –v –v 1000 >c:\monkey.txt
Monkey View Package Name
Install APK package Name Viewer in your phone
Androidmanifest.xml file view under source code
AAPT Command View
Monkey Log Analysis
Normally, if the Monkey test completes successfully, at the end of the log, the number of times the current execution event is printed and the time spent;//Monkey finished represents execution completion \
Abnormal conditions
Monkey test errors occur, the general analysis steps
Watch Monkey's log (note the first Swith and exception information, etc.)
1. Program unresponsive issue: Search the log for "ANR"
2. Crash: Search for "Exception" in the log (if a null pointer appears, nullpointerexception) there must be a bug.
Monkey execution interrupt, the current number of executions can also be seen at the end of log
Must pay attention to crash
Although the monkey test has some defects, we can not accurately know the repro step, monkey Test nullpointexception, are available to users, when it appears only a matter of time
Theoretically, all of Monkey's crash need to be repaired before release.
This article transferred from: https://www.cnblogs.com/TankXiao/p/4815134.html
Introduction to Android Monkey stress test