Appium自动化测试教程-自学网-monkey日志管理

 

日志管理作用

Monkey日志管理是Monkey测试中非常重要的一个环节,通过日志管理分析,可以获取当前测试对象在测试过程中是否会发生异常,以及发生的概率,同时还可以获取对应的错误信息,帮助开发定位和解决问题。

monkey日志保存方法

1. 保存在PC中

2. 保存在手机上

3. 标准流和错误流分开保存

保存在PC中

>adb shell monkey [option] <count> >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] <count> 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

 

上一篇:android-给onTouch优先于onClick


下一篇:【Linux常见命令】touch命令