当前位置:网站首页>[monkey] Introduction to monkey test
[monkey] Introduction to monkey test
2022-06-28 10:37:00 【Spinach in spring】
Catalog
Two 、 Real machine or simulator
5、 ... and 、 Analysis of test results
( One ) Preliminary analysis method
( Two ) General test result analysis :
One 、 install
install jdk8 and android-sdk Environmental Science , Search on the Internet
Verify installation results

Two 、 Real machine or simulator
Note that the developer mode , as well as usb mode
This article uses the simulator
3、 ... and 、 Basic commands
adb shell monkey + Behavioral parameters + ">" + { Log save path }
# A few common commands
1、adb shell monkey 100 monkey Command execution 100 Random events
2、adb shell monkey - run p akp Package name 1000 Specify the package name to test
3、adb shell monkey --ignore-crashes 100 Ignore the crash
4、adb shell monkey --ignore-timeouts 100 Ignore timeout
5、adb shell monkey -v 100 Specify the log detail level
6、adb shell monkey -s seed Number 34432221000 Specify the seed number
7、adb shell monkey --throttle 100 100 Specify the event delay 100 millisecond
8、adb shell monkey --pct-touch 10 1000 Specifies the percentage of touch events 10%
9、adb shell monkey --pkg-whitelist-file/data/tmp/whitelist.txt 1000 Whitelist test Small demo:
adb shell monkey -p com.xxx.myapp --throttle 100 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v 1000000 > d:\mylog.log
# com.xxx.myapp appPackage name adb shell pm list packages (-f: Package names of all applications ,-3: Package name of non system installation )Case scenario :
Need control monkey Execution time , You can set the execution time / Event sending delay , Calculate the number of times to execute .
Such as : to want to monkey function 24 Hours , Every time 100 Send an event in milliseconds .24*60*60*1000/100=864000( Time )
adb shell monkey -p *** -v -v -v --ignore-crashes --ignore-timeoutss --throttle 100 864000 >D:\monkey.log
Express : this monkey Will run 24 Hours
Command parameter :
monkey The command parameters of are divided into :
Basic parameters :-v 、-s 、-p 、--throttle etc.
Debugging options :--ignore-crashes etc.
Event type :--pct-touch etc.
( One ) Basic parameters
1、 The simplest monkey command (monkey 100)
Express : On the device , Send... For the whole system 100 A pseudo-random event .
2、-v Parameters
Used to specify the feedback level ( The level of information is the level of detail of the log ) The total is divided into 3 level , The default is -v( Corresponding :level0)
-v: Only startup prompt is provided 、 A small amount of information such as test completion prompt and final result .
-v -v: A more detailed log , Include each sent to activity Time information of .
-v -v -v: The most detailed log , Including... Selected in the test / Unselected activity Information .
Be careful : stay monkey When the test is complete , There must be one in the end :monkey finished identification .
3、-p Parameters
When we test , It's specific app Tested by , So it's using monkey When testing , We need to provide specific app Package name to monkey, In this case, you need to use the parameters -p. stay -p Heel follow app Package name .
At testing time , You can not specify the package name , here monkey Will start randomly on the test equipment app To operate ; If you only need to test one app, Use one -p that will do ; If there are more than one app Test at the same time , You can use it directly -p Package name 1 -p Package name 2 Specify the specific... To be tested app.
4、-s Parameters
Seed value (seed), because monkey Is sending a pseudo-random stream of events , But if twice seed Same value , Those two times monkey The sequence of events generated by the test is the same .( Therefore, it is generally necessary to record when testing seed value , In case of non response and crash, Not easy to verify .)
Be careful :-s You need to follow the package name , A few times ago
5、--throttle Parameters
Set the delay time for executing the operation ( millisecond )-- Is the interval between two events , If this parameter is not specified , Will generate and send events as quickly as possible .
( Two ) Debugging options
1、--ignore-crashes
Used to specify when the application crashes ,Monkey Whether to stop operation . If you use this parameter , Even if the application crashes ,monkey Events will still be sent , Until the event count is complete .
2、---ignore-timeouts
Used to specify when an application occurs ANR(Application No Responding) When it's wrong ,Monkey Whether to stop operation . If you use this parameter , Even if the application happens ANR error ,Monkey Events will still be sent , Until the event count is complete .
3、--ignore-security-exceptionss
Used to specify when a license error occurs in the application ( If the certificate permits , Network license, etc ),Monkey Whether to stop operation . If you use this parameter , Even if the application has a license error ,Monkey Events will still be sent , Until the event count is complete .
4、--kill-process-after-error
Used to specify when an error occurs in the application , Whether to stop its operation . If you specify this parameter , When an error occurs in the application , The application stops running and remains in its current state ( Be careful : The application is only static when an error occurs , The system does not end the process of the application ).
5、--monitor-native-crashes
Local code used to specify whether to monitor and report application crashes
6、--hprof
After this option is set , Will be in monkey The sequence of events is generated immediately before and after report, The size is greater than 5MB, Stored in /data/misc
( 3、 ... and ) Event type
monkey When sending pseudo-random Events , There are different types . Default random allocation ratio , You can also specify its percentage . If it is not set, it will be --pct-anyevent by 100%, That is, pure random events ; If other parameters are configured , But not enough 100%, The remaining percentage is also --pct-anyevent event .
The specific event types are :
1: Touch event --pct-touch
adjustment touch Percentage of touch screen events , A touch event is a click at a single location on the screen / Raised event .
2: Sliding screen event --pct-motion( Gesture events )
( A gesture event is a press event somewhere on the screen 、 A series of pseudo-random moves 、 A lift event consists of ) It's a sliding operation , But it's straight , No turning )
3: trackball --pct-trackball
( Trackball events include one or more random movements , Sometimes it's accompanied by a click . Trackball is no longer available on smartphones , It's like the direction key of the handle )
4: rotate (--pct-rotation)
Rotate screen
5: Navigation --pct-nav
( Navigation events include up, down, left and right , Such as the input of the direction input device ) Old mobile phone up and down around the key , There's No... on the smartphone )
6: Main navigation --pct-majornav
Adjust the percentage of major navigation events ( Such as middle key 、 Cancel 、 Determine the action of the graphic interface caused by the menu )
7: System buttons --pct-syskeys
Adjust system key events , Such as :home/back/startcall/endcall And volume control keys
8:app Switch --pct-appswitch
Adjust startup activity Percent of , At random intervals , Execute one startActivity() Method call , As a way to maximize the coverage of all installation packages activity Methods
9: Keyboard flip (--pct-flip)
10: Random --pct-anyevent
Adjust the percentage of other types of events , Such as the percentage of keystrokes or other less common events



Four 、 Stop the order
1)adb shell ps
Find out com.android.commands.monkey The process of PID
2) Kill the process
adb shell kill pid5、 ... and 、 Analysis of test results
( One ) Preliminary analysis method
Monkey After a test error , The general error checking steps are as follows :
1、 Find is monkey What's wrong in there
2、 see Monkey Some of the events and actions before the error , And perform the action manually
3、 If the above steps can't find out , You can use the previously executed monkey The command is executed again , Be careful seed The value should be the same -- Reappear
( Two ) General test result analysis :
1、 ANR problem : Search the log for “ANR”
2、 Breakdown problem : Search the log for “Exception” Force Close
Sources of information :
边栏推荐
- Installing MySQL database (CentOS) in Linux source code
- DlhSoft Kanban Library for WPF
- ECS MySQL query is slow
- Katalon框架测试web(二十)自定义关键字以及上传弹窗操作
- 建立自己的网站(11)
- [unity][ecs] learning notes (III)
- Katalon当中的使用循环for、while和if...else、break、continue
- 【力扣——动态规划】整理题目1:基础题目:509、70、746、62、63、343、96(附链接、题目描述、解题方法及代码)
- OpenHarmony应用开发之二维码生成器
- MySQL (I)
猜你喜欢

物联网5种无线传输协议特点大汇总

手把手教你处理 JS 逆向之 SVG 映射

增强 Jupyter Notebook 的功能,这里有四个妙招

Information hidden in the trend chart of Hong Kong London gold market

无线通信模块定点传输-点对多点的具体传输应用

As shown in the figure, the SQL row is used to convert the original table of Figure 1. Figure 2 wants to convert it

Day 6 script and animation system

移动命令
![[unity][ecs] learning notes (I)](/img/eb/1f0ad817bbc441fd8c14d046b82dd0.png)
[unity][ecs] learning notes (I)

DlhSoft Kanban Library for WPF
随机推荐
Several methods of using ABAP to operate Excel
Katalon框架测试一个web页面操作实例代码
JSON模块、hashlib、base64
Dotnet uses crossgen2 to readytorun DLL to improve startup performance
工控安全之勒索病毒篇
Bytecode proof in appliedzkp zkevm (9)
Understanding of FTP protocol
Guangzhou Customs supports the stable supply of food, agricultural products, traditional Chinese medicine and other civilian and biological resources to Hong Kong
Resolution: overview of decentralized hosting solution
Read PDF Text and write excel operation
MySQL (III)
fastposter v2.8.4 发布 电商海报生成器
Mongo数据库
[leetcode daily question] [December 19, 2021] 997 Find the town judge
Set up your own website (11)
Minimum stack < difficulty coefficient >
建立自己的网站(11)
[Unity][ECS]学习笔记(三)
[200 opencv routines] 213 Draw circle
Training and recognition of handwritten digits through the lenet-5 network built by pytorch