当前位置:网站首页>Chapter IX app project test (4) test tools
Chapter IX app project test (4) test tools
2022-06-29 15:11:00 【zhhzc】
Follow the above article continue
(7)--kill-process-after-error
Parameter description : Used to specify when an error occurs in the application , Whether to stop operation . If you specify this parameter , When an error occurs in the application , The application stops running and saves the current state ( The application only stops when sending errors , The system does not end the process of the application )
Example :adb shell monkey-pcom.android.music--kill-process-after-error 1000
During the test , If music Send error ,monkey Will stop running and save in the current state .
(8)-hprof
Parameter description : If you set this option in Monkey Generate profiling reports before and after the event sequence . This will be in the data /misc Generate large (5MB) file , Please use this option with caution
【 Event options 】 There are mainly --pct-[touch、motion、trackball、syskeys、nav、majornav、apps-witch、flip、rotation、anyevent、pinchzoom] etc. .
Monkey You can specify the percentage of multiple types of events at the same time , But the total cannot exceed 100%
(1)--pct-touch<percent>
Parameter description : Adjust the percentage of touch events , The touch event is a “ Press down ”“ lift ” The event happened somewhere on the touch screen .
Example :adb shell monkey-pcom.music-pct-touch 101000
Set the percentage of touch events tested to 10%
(2)pct-motion<percent>
Parameter description : Adjust the percentage of action events , The action event consists of a press event somewhere on the screen 、 Random events and lift events are organized .
Example :adb shell monkey-pcom.android.calendar--pct-motion 201000
Indicates that the cost ratio of setting action events is 20%
(3)--pct-trackball<percent>
Parameter description : Adjust the percentage of track events , The fund return event consists of one or several random mobile events , Sometimes it's accompanied by clicks .
Example :adb shell monkey-pcom.android.calendar--pct-trackball 301000
Indicates that the percentage of track events is set to 30%
(4)--pct-syskeys<percent>
Parameter description : Adjust the percentage of system key events , System keys refer to HOME、BACK、POWER、 The volume +、 The volume - Wait for the button .
Example :adb shell monkey-pcom.android.calendar--pct-syskeys 601000
(5)-pct-nav<percent>
Parameter description : Adjust the percentage of basic navigation events , The basic navigation event consists of up、down、left、right form
Example :adb shell monkey-pcom.android.calendar--pct-nav 301000
6)--pct-majornav<percent>
Parameter description : Adjust the percentage of major navigation events , These navigation events are mainly some key events in the keyboard .
Example :adb shell monkey-pcom.android.calendar--pct-majornav 501000
(7)--pct-appswitch<percent>
Parameter description : Adjust startup APP Activity percentage . That is, the percentage of active controls that are invoked .
(8)--pct-flip<percent>
Parameter description : Percentage of keyboard flip events
(9)--pct-rotation<percent>
Parameter description : Set the percentage of rotation events , Is to set the screen turning action of the application .
Example :adb shell monkey-pcom.android.calendar--pct-rotation 1001000
Indicates setting application camera The percentage of screen turning events is 100
(10)--pct-anyevent<percent>
Parameter description : Adjust the percentage of other types of events , Including all other types of events .
(11) There are mainly --pct-pinchzoom
Parameter description : Adjust the zoom event percentage
4、Monkey test result Log analysis
1) normal Log, It is generally composed of these , List Monkey Parameters set at runtime

2) When something unusual happens ,Log Mainly by 2 Kind of , One is crash Information , This will happen after application crash Log, The other is ANRlog.
crash log analysis
stay log Search for crash, If you find crash, It indicates that the application has failed , There are many reasons , Mainly by NullPointerException( Null pointer exception )、 lllegalStateException( Illegal pointer parameter )OutOfMemoryError( Low memory exception )
ANRLog analysis
stay Log Search for ANR, If you can find , It indicates that there has been no response from the application in China during the test process . appear ANR Possible causes of : A process takes too long to process 、 Application wait timeout 、 The application itself timed out waiting for the network 、 Related application processing is not synchronized 、 Cause to wait all the time .
Other abnormalities :Restart System abnormal ( System restart )RuntimeException(Android function When abnormal )、Stale DataException、ReadException( Data processing exception )
3) If an exception occurs during the test Log Analysis for developers . It is recommended to combine... During the test logcat Capture logs in real time to analyze problems .
5、Monkey Precautions during test
(1) Prepare the preconditions for testing
Do some preparatory work , For example, the mobile phone needs to follow the application 、SD What data does the card need .
(2) Careful use ADB
Usually in 2 In this case Monkey test ; Working time or rest time . If during working hours , Want to execute on the simulator or real machine Monkey Do other work while testing , Remember to use carefully adb Related commands , In especial adb kill-server Such an order . because Monkey It's through adb shell Command initiated , When used for some reason adb Command to restart adb service ,Monkey The logging of the test will be terminated , There will be no corresponding logging after the test , If the test finds a rout problem , Will not record log journal , It is difficult to analyze the problem .
3) Simultaneous recording Android System routine
perform Monkey While testing , At the same time adb logcat Information .
4) Need record seed value
seed Value is the only one that can reproduce Monkey The method of the crash problem in the test . When one Monkey The method of the crash problem in the test . When one Monkey After the test problems are fixed , Sometimes I don't know how to verify , At this time, you can only use the same parameters , same seed Value to be reproduced for verification .
5) Don't use a single command
You can write a few more tests with different emphasis monkey The test command , Use these commands simultaneously in a project to test , So as to achieve different test results in each test , Find more defects .
6) Attaches great importance to crash
monkey What happens in the test NullPointException( The pointer runs away ) And so on can appear when users use , It's only a matter of time before it happens . therefore monkey be-all crash All need to be repaired before the split
9.4.4 DDMS
yes Dalvik Debug Monitor Service Abbreviation , It's actually Android Debugging and listening server of virtual machine . It passes through the port forwarding service 、 Device screen capture 、 Thread and heap information on the device 、logcat Information 、 Process and broadcast status information 、 Incoming calls and SMS simulation 、 Geographical location data simulation, etc .
DDMS Work on equipment or simulator , If the real device or simulator is running at the same time and connected to the computer , that DDMS Start the device view service . When the device is connected ,adb and DDMS A virtual machine monitoring service has been established , It will improve DDMS" When does the virtual machine on the device start , When to terminate “ Once the virtual machine is running ,DDMS adopt (adb deamon Daemon ) Establish a connection to the virtual machine debugger .DDMS It can communicate with the virtual machine through corresponding protocol .
Run... Under the command ddms You can start it DDMS, start-up DDMS Before that, you need to run the simulator or connect the equipment .
2、DDMS The function of
DDMS Integrated into the android In the virtual machine , Used to manage processes running on emulators or devices , And assist in commissioning . You can use it to select a program to debug 、 Generate tracking data 、 View heap and thread data 、 Screen shot of simulator or equipment, etc .
(1) start-up DDMS
Before starting, you need to connect the device or simulator . Then run the command ddms You can start it DDMS, The interface after startup is as shown in the figure 9-9 Shown 
( Split in the figure 3 Large module , The first module is the process running in the device or simulator . The first 2 The module has multiple tabs 、 Include info、Threads、VM、Heap、Sysinfo Network etc. . The first 3 The module displays the log information of the application )
(2) Information log information --logcat
Logcat Used to display debugging information in the system , Invoked in a program Log The output information of class functions is output here . Pictured 9-9 The third module shows .logcat A lot of log information is output in , Different levels of information can be selected for display , Level of log display , As shown in the table 9-3
(3) Thread tab -Threads
The information of all threads in the current process in the target virtual machine is shown in the figure 9-10 Shown ,

Shows the process com.freshO2O Thread information . among ID Represents the thread in the virtual machine ID,Tid Express Linux Threads ID, Follow
PID Agreement ,Status Indicates the status value ( The state values are Runnable Being implemented 、wait Waiting for execution 、monitor Waiting to acquire a listening lock ), belt “*” Represents daemons ,Utime Indicates the cumulative time of application execution ,Stime Indicates the cumulative time of system execution Name Indicates the thread name .
(4) Memory heap status information VM heap
First, in the 9-11 In the figure

Click on the picture (show heap update), Then click (Cause an im-mediate GC) It's in VM heap The virtual machine memory heap information is displayed in the tab . Displays the memory usage of the current process , among ,Heap Size Indicates the total memory size that the process can use ,Allocated Indicates the memory space currently used by the process ,Free Indicates the remaining memory space , Pictured 9-11 Shown .
(5) Generative analysis .hprof file
In the figure 9-11 Middle click Dump HPROF fule Can grasp heap dump file , Its extension is hprof, Developers analyze heap dump You can find out if there is a memory leak in the application .
(6) Import and export
On the launch page , menu bar Device Next , single click File Explorer It will list all files on the current device or simulated machine , Pictured 9-12 Shown .

You can also export files on the device or emulator to PC End , It's fine too PC Copy the files on the terminal to the device or emulator .
(7) Save the screenshot
It also provides a screenshot function , When problems are found during the test , And want to save the scene , have access to ddms To save the screenshot , Specific operation : In the menu bar of the startup interface Device Next , single click “Screen capture" Button , Click... In the figure that appears “Save”
Button to save . Then select the save path to save , Last saved as .png file .
边栏推荐
- PostgreSQL learning (based on rookie course)
- MySQL中100w数据表比1000w数据表查询更快吗?
- Differential equations of satellite motion
- 西北工业大学遭境外电邮攻击
- If I am in Foshan, where can I open an account? Is it safe to open an account online?
- 信息学奥赛一本通2061:梯形面积
- 投资reits基金是靠谱吗,reits基金安全吗
- Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen
- MCS:离散随机变量——Binomial分布
- Lumiprobe 活性染料丨环炔染料:AF488 DBCO,5 异构体
猜你喜欢

真正的软件测试人员 =“半个产品+半个开发”?

Uniapp problem list and experience

Lumiprobe deoxyribonucleic acid alkyne DT phosphimide

Secondary pointer

Redis installation in windows and Linux Environment

技术沟通遇到3个为什么背后的逻辑

打造一个 API 快速开发平台,牛逼!

Lumiprobe reactive dye cycloalkyne dye: af488 dbco, 5 isomer

Construction and application of medical field Atlas of dingxiangyuan

Lumiprobe 活性染料丨羧酸:Sulfo-Cyanine7.5羧酸
随机推荐
Hi,你有一份Code Review攻略待查收
Differences between @resource and @autowired annotations automatically injected:
The first lesson on cloud - how easy is it to build a small broken station? The old driver of cloud computing will take you one hour to finish it
How word automatically generates directories
June 27 talk SofiE
信息学奥赛一本通1194:移动路线
You need to know about project procurement management
Configuration tutorial for swagger2
Query function of Excel vlookup
Illustration of Ctrip quarterly report: net revenue of RMB 4.1 billion has been "halved" compared with that before the outbreak
Imitation headline news information DZ template discuz news information business version GBK template source code
China soft ice cream market forecast and investment prospect research report (2022 Edition)
Lumiprobe reactive dye miscellaneous dye: BDP FL ceramide
Yi Ming ang Ke rushed to Hong Kong shares: loss of 730million in the year Lilly and sunshine life insurance were shareholders
How bad can a programmer be?
威高血液净化冲刺香港:年营收29亿 净利降12.7%
高並發軟件(網站,服務器端接口)的評價指標
中国二氧化硫脲行业研究与发展前景研究报告(2022版)
模电 2个NPN管组成的恒流源电路分析
文本预处理库spaCy的基本使用(快速入门)