monkey 日志管理
时间:2022-09-28 13:30:00
日志管理功能
Monkey日志管理是Monkey通过日志管理分析,可以获得当前测试对象在测试过程中是否会出现异常和概率,也可以获得相应的错误信息,帮助开发定位和解决问题。
monkey日志保存方法
- 保存在PC中
- 保存在手机上
- 标准流和错误流分开保存
保存在PC中
>adb
shell monkey [option] >d:\monkey.txt
eg
:
C:\Users\Shuqing>adb
shell monkey -v -v 100 >d:\monkeylog.txt
保存在手机上
C:\Users\Shuqing>adb
shell
monkey -v 100 >/sdcard/monkeylog.log
注:不能写C:\Users\Shuqing>adb shell monkey -f /sdcard/kyb.txt -v 1 > /mnt/sdcard/monkey.log 否则,系统找不到指定指定路径。
标准流和错误流分开保存
·代码如下:
Monkey [option]
1>/sdcard/monkey
.txt
2>/sdcard/error
.txt
C:\Users\Shuqing>adb shell monkey -v
100
1>d:\monkey
.log
2>d:\error
.log
执行上述命令,Monkey分别保存运行日志和异常日志。Monkey将保存在运行日志中monkey.txt在文件中,异常日志将保存在D盘下error.txt中。
日志内容分析
运行命令:
adb
shell monkey -v 100
运行后log如下:
C:\Users\Shuqing>adb shell monkey -v 100
:Monkey: seed=1524595418646 count=100
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
// 0: 15.0%
// 1: 10.0%
// 2: 2.0%
// 3: 15.0%
// 4: -0.0%
// 5: 25.0%
// 6: 15.0%
// 7: 2.0%
// 8: 2.0%
// 9: 1.0%
// 10: 13.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.settings/.Settings;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.settings/.Settings } in package com.android.settings
:Sending Touch (ACTION_DOWN): 0:(381.0,391.0)
:Sending Touch (ACTION_UP): 0:(371.61426,386.54578)
:Sending Touch (ACTION_DOWN): 0:(608.0,610.0)
:Sending Touch (ACTION_UP): 0:(609.2884,609.54736)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,4.0)
:Sending Touch (ACTION_DOWN): 0:(42.0,319.0)
:Sending Touch (ACTION_UP): 0:(40.672623,306.90936)
:Sending Touch (ACTION_DOWN): 0:(577.0,372.0)
:Sending Touch (ACTION_UP): 0:(521.3876,386.2045)
:Sending Touch (ACTION_DOWN): 0:(59.0,762.0)
:Sending Touch (ACTION_UP): 0:(92.18322,695.0543)
:Sending Touch (ACTION_DOWN): 0:(46.0,1066.0)
:Sending Touch (ACTION_UP): 0:(118.78821,1042.1993)
:Sending Touch (ACTION_DOWN): 0:(525.0,696.0)
:Sending Touch (ACTION_UP): 0:(557.81305,684.04376)
:Sending Touch (ACTION_DOWN): 0:(466.0,12.0)
:Sending Touch (ACTION_UP): 0:(453.73657,10.844121)
:Sending Trackball (ACTION_MOVE): 0:(0.0,1.0)
Events injected: 100
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=924ms (0ms mobile, 0ms wifi, 924ms not connected)
// Monkey finished