当前位置:网站首页>[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 :
边栏推荐
猜你喜欢

Training and recognition of handwritten digits through the lenet-5 network built by pytorch

Ruoyi integrated building block report (NICE)

一种跳板机的实现思路
![[Unity]EBUSY: resource busy or locked](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[Unity]EBUSY: resource busy or locked

Markdown -- basic usage syntax

【monkey】monkey测试入门

Wireless communication module fixed-point transmission - point to multipoint specific transmission application

etf持仓如何影响现货金价?

Understand 12 convolution methods (including 1x1 convolution, transpose convolution and deep separable convolution)

Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
随机推荐
Dear leaders, ask me if MySQL does not support early_ Offset mode? Unsupported star
[200 opencv routines] 213 Draw circle
[unity] built in rendering pipeline to URP
MySQL cannot be opened. Flash back
Mysql database overview and installation process
满电出发加速品牌焕新,长安电动电气化产品吹响“集结号”
引入 flink-sql-mysql-cdc-2.2.1 好多依赖冲突,有解决的吗?
sentinel
Fabric. How to use js brush?
Day 6 script and animation system
一种跳板机的实现思路
Katalon框架测试web(二十)自定义关键字以及上传弹窗操作
【功能建议】多个工作空间启动时选择某个空间
工控安全之勒索病毒篇
Chapter 5 trees and binary trees
linux中源码安装mysql数据库(centos)
OpenHarmony应用开发之二维码生成器
2D code generator for openharmony application development
增量快照 必须要求mysql表有主键的吗?
Hystrix 部署