通过一系列参数和事件的了解,我们也看到了用 monkey 进行稳定性测试其实很简单。但是经过 monkey 测试后,要如何去分析测试的结果呢?怎么才知道应用是否稳定?
要获取 monkey 的执行结果,最好的方式是分析 monkey 执行过程中产生的日志。
获取 monkey 日志
要获取 monkey 日志的话,通过重定向
命令即可。
示例:
adb shell monkey -p com.huomaotv.mobile --pct-appswitch 20
--pct-rotation 20 --pct-touch 30 --pct-motion 20
--ignore-crashes --ignore-timeouts --monitor-native-crashes 10000 > d:/monkey.log
在命令的最后,加上>
重定向到本地文件。d:/monkey.log
放在 d 盘的根目录。
分析日志
那么对于 monkey 跑完之后,我们要如何去确认有没有出现 bug 呢?
最直观简单的方式就是通过搜索以下关键字:
- 程序无响应的情况:搜索关键字
ANR in
- 崩溃的情况1:搜索关键字
CRASH
- 崩溃的情况2:搜索关键字
Exception
如下,为一个 Crash 的例子:
procrank:
// CRASH: com.huomaotv.mobile (pid 3071)
// Short Msg: Native crash
// Long Msg: Native crash: Aborted
// Build Label: Android/vbox86p/vbox86p:6.0/MRA58K/91:userdebug/test-keys
// Build Changelist: 91
// Build Time: 1526948635000
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Build fingerprint: 'Android/vbox86p/vbox86p:6.0/MRA58K/91:userdebug/test-keys'
// Revision: '0'
// ABI: 'x86'
// pid: 3071, tid: 3193, name: RenderThread >>> com.huomaotv.mobile <<<
// signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
// Abort message: 'Encountered EGL error 12291 EGL_BAD_ALLOC during rendering'
// eax 00000000 ebx 00000bff ecx 00000c79 edx 00000006
// esi dbb3f980 edi 00000004
// xcs 00000023 xds 0000002b xes 0000002b xfs 00000107 xss 0000002b
// eip f73196c6 ebp 00000c79 esp dbb3f150 flags 00200206
// backtrace:
// #00 pc 000836c6 /system/lib/libc.so (tgkill+22)
// #01 pc 00081728 /system/lib/libc.so (pthread_kill+70)
// #02 pc 00027255 /system/lib/libc.so (raise+36)
// #03 pc 00020a34 /system/lib/libc.so (abort+80)
// #04 pc 0000cbd3 /system/lib/libcutils.so (__android_log_assert+128)
// #05 pc 00023759 /sys
网友评论