当前位置:网站首页>[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 :
边栏推荐
- 一款自动生成单元测试的 IDEA 插件,开发效率提升 70% 以上!
- Chapter 3 stack and queue
- Hystrix deployment
- Wireless communication module fixed-point transmission - point to multipoint specific transmission application
- flink1.15,支持mysql视图吗?我这边在table-name处配置视图名保存,找不到表。想
- Six fusion positioning technologies in wireless communication application of Internet of things
- Summary of characteristics of five wireless transmission protocols of Internet of things
- Katalon全局变量在TestObject引用
- AQS理解
- 手把手教你处理 JS 逆向之 SVG 映射
猜你喜欢

Set up your own website (11)

Fastposter v2.8.4 release e-commerce poster generator

DlhSoft Kanban Library for WPF
![[unity][ecs] learning notes (I)](/img/eb/1f0ad817bbc441fd8c14d046b82dd0.png)
[unity][ecs] learning notes (I)

【monkey】monkey测试入门

Idea failed to connect to SQL Sever

sentinel

港伦敦金行情走势图所隐藏的信息

Resolution: overview of decentralized hosting solution

Solve the problem that the value of the action attribute of the form is null when transferring parameters
随机推荐
MySQL general binary installation method
Teach you how to handle the reverse SVG mapping of JS
Fabric. How to use js brush?
AQS理解
移动命令
Google open source dependency injection framework Guice Guide
Understand 12 convolution methods (including 1x1 convolution, transpose convolution and deep separable convolution)
请教下, 我在本地idea运行flinkcdc的mysql到mysql全量同步,这个是在我本地ide
Hystrix 部署
Must the MySQL table have a primary key for incremental snapshots?
Redis数据库
Generate token
一文读懂 12种卷积方法(含1x1卷积、转置卷积和深度可分离卷积等)
Training and recognition of handwritten digits through the lenet-5 network built by pytorch
Fabric.js 笔刷到底怎么用?
appliedzkp zkevm(10)中的Transactions Proof
【LeetCode每日一题】【2021/12/19】997. 找到小镇的法官
MySQL(二)
Mongo database
[unity][ecs] learning notes (I)