跑三小时的monkey测试该怎么算_monkey测试方法

1.测试准备

1.1打开USB调试模式,确保adb可以连接;

1.2把屏幕灭屏时间设置为“永不”,屏幕解锁;

1.3插入sim卡和存储卡。(可选)

1.4 打开已经安装的app,简单使用,授予app申请的权限。

1.5测试前清除历史LOG(仅ZUK项目需要)点击一次“*#*#3333#*#*”中“保存”即可。

1.6打开“*#*#3333#*#*”中的各个模块日志(不含modem)(仅ZUK项目需要)

1.7启动“大量日志模式”点击“*#*#3333#*#*”中的“应用日志”8次,会显示log录制模式,选择“无限模式”;此模式下系统录制的log总量大,会覆盖较长时间。

1.8Moto项目需配置Bug2Go,打开aplogd服务

2.Monkey测试

参数说明:

“2> /sdcard/error.txt”表示错误信息输出到/sdcard/error.txt

“1> /sdcard//info.txt” 表示一般信息输出到/sdcard//info.txt#

当通过USB链接手机时,即输入monkey命令后,不关闭命令窗口时,error会输出到窗口(shell或者CMD),此时需要确保窗口可以完整的保存输出log,推荐使用MobaXterm,或者直接关闭窗口(断开USB链接),此时error信息输出到文件error.txt。

#当做长时间monkey测试时,手机需要连接到电源上,以防电量耗尽,自动关机。

2.1 指定特定包测试

adb shell

monkey -p com.zui.browser--ignore-crashes --ignore-native-crashes --ignore-timeouts --ignore-security-exceptions --throttle 500 -v -v -v 100000 2> /sdcard/error.txt 1> /sdcard/info.txt

此命令指定测试包com.zui.browser,可根据实际情况替换成需要的包名。支持同时指定多个包名,如:“-p com.zui.browser-p com.zui.weather”

2.2 系统测试

此命令用于User版本,如果测试Userdebug版本推荐使用“4.2 黑名单测试”。

adb shellmonkey --ignore-crashes --ignore-native-crashes --ignore-timeouts --ignore-security-exceptions --throttle 500 -v -v -v 10000000 2> /sdcard/error_sys.txt 1> /sdcard/info_sys.txt

2.3白名单测试

使用参数“--pkg-whitelist-file PACKAGE_WHITELIST_FILE”apk白名单,只测试包含在白名单中的apk

编写白名单文件“white_list.txt”,文件内容是app的包名,每个app包名占一行。如:com.zui.browser

com.zui.calendar

将“white_list.txt”push到手机的“/sdcard”目录

adb push 'C:\Users\wangwq14\Desktop\white_list.txt' /sdcard/

执行命令:adb shell

monkey --pkg-whitelist-file /sdcard/white_list.txt --ignore-crashes --ignore-native-crashes --ignore-timeouts --ignore-security-exceptions --throttle 500 -v -v -v 100000 2> /sdcard/error_white.txt 1> /sdcard/info_white.txt

2.4黑名单测试

使用参数“--pkg-blacklist-file PACKAGE_BLACKLIST_FILE”Apk黑名单,不测试包含在黑名单中的apk,测试系统以及其它app。

编写黑名单文件“black_list.txt”,文件内容是app的包名,每个app包名占一行。如:com.motorola.cdbench2

com.android.development

com.motorola.bug2go

com.motorola.tools.batterytracer

com.test.desense

com.motorola.iqdataupload

com.motorola.iplog

com.lenovo.mgc

com.motorola.survey

com.motorola.perfmonitor

com.motorola.pmtest

com.qual

comm.qti.sensors.qsensortest

com.motorola.imagertuning_albus

(黑名单包括但不限于以上app,他们大都是Userdebug版本中的内部调试app,不需要也不能参与monkey测试)

将“black _list.txt”push到手机的“/sdcard”目录

adb push'C:\Users\wangwq14\Desktop\black_list.txt' /sdcard/

执行命令:adb shell

monkey --pkg-blacklist-file /sdcard/black_list.txt --ignore-crashes --ignore-native-crashes --ignore-timeouts --ignore-security-exceptions --throttle 500 -v -v -v 1000000 2> /sdcard/error_black.txt 1> /sdcard/info_black.txt

3. 结果判断

Monkey测试完毕后,打开monkey的info.txt文件,拖到最后,判断monkey是否执行成功。

如果info.txt中Events injected的数量是预设定的值, 恭喜你的模块通过了Monkey测试,后续可继续更改seed和加大COUNT数量进行测试。

Events injected: 100000

:Dropped: keys=9160 pointers=23173 trackballs=0 flips=0

## Network stats: elapsed time=7611291ms (0ms mobile, 0ms wifi, 7611291ms not connected)

// Monkey finished

失败的log中有Monkey错误信息,Events injected的数量小于预设定的值:

** Monkey aborted due to error.

Events injected: 14290

:Dropped: keys=0pointers=38 trackballs=0 flips=0

## Network stats: elapsed time=4025256ms (0ms mobile, 0ms wifi, 4025256ms not connected)

** System appears to have crashed at event 14290 of 100000 using seed 6666

请注意:不管成功与否,请打开/data/error.txt,查看其中有没有异常,如果有异常要报问题给相关研发处理。

说明:logcat中“04-18 17:58:10.715 19827 19827 D AndroidRuntime: Calling main entry com.android.commands.monkey.Monkey”表示monkey开始的时间

info.txt中的“## Network stats: elapsed time=111203ms (0ms mobile, 0ms wifi, 111203ms not connected)”elapsed time表示monkey经历的时间

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值