Introduction
Logs are very important. They are used to record system and software operation events. Record files or file collections can be divided into event logs and message logs. It plays an important role in processing historical data, diagnosing problem tracking, and understanding system and software activities. If there is a problem in the process of developing or testing a soft system, the first thing we think of is her——logging. She is not like what Tagore said: "The sky has not left traces of wings, but I have already flown over"; the little girl Monkey, she is a person who loves to show off and show off. realm. As long as we follow the map, we will be able to locate the problem, then analyze the problem and solve the problem. Alright, let’s have fun, let’s get into today’s topic.
1. Why look at Monkey log management
Monkey log management is a very important part of Monkey testing. Through log management analysis, it is possible to obtain whether the current test object is abnormal during the test process, and the probability of occurrence. At the same time, it can also obtain the corresponding error information to help the development and positioning. Solve the problem. In this way, you will not just stop at a little bit of work, and it is also a good improvement for yourself.
2.Monkey Log analysis:
When there is a problem during the monkey test, we need to analyze the positioning problem at this time, we need to analyze the monkey log
The reason for the abnormality in the Monkey test:
generally it is caused by two reasons, one is that the crash program crashes, and the reasons for the crash are as follows:
a), there is a null pointer in the program
b), insufficient cpu
, and insufficient memory
The other is that the ANR program is unresponsive, and the reasons for anr unresponsiveness are as follows:
a) Thread blocking
b) Insufficient cpu
c) Insufficient memory
Find out why:
1. When the monkey test terminates abnormally, please open the logcat log and search for the keyword 'anrin'. If this keyword exists, it means that the app has an ANR exception. We need to remove the trace.txt file in the /data/anr directory.
2. After removing the trace.txt file, send the log corresponding to the problematic process number to the software engineer for location. If the keyword 'anrin' is not found in the logcat log, search for the upper and lower logs of the abnormal keyword 'nullpointer' , send it to the development location
3. When ANR appears, it needs to be exported, the steps are as follows:
1. Enter adb shell
2. Enter cd /data/anr/
3. Enter ls
After exiting exit, directly enter 4. adb pull /data/anr/traces.txt d:\trace.txt in cmd
5. Copy the process number of the anr problem in logcat, and then press ctrl+ in the trace.txt file F Find, paste the process number, find the corresponding problem
2.1Monkey result classification
Monkey runs the log output in the following order
The following is the detailed LOG analysis I posted: (emoticons replace comment symbols, so as not to confuse with logs)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
3.快速从monkey.txt日志中定位问题
3.1测试结果初步判断
1.monkey执行时未加--ignore-crashes
--ignore-crashes
参数,就先浏览日志中Events injected: 值
,查看当前已执行的次数,就知道有无bug
2.程序无响应的问题:在日志中搜索 “ANR”
3.崩溃问题:在日志中搜索 “Exception” ,在这里顺便提一下常见的Java异常:
1 算术异常类:ArithmeticExecption 2 空指针异常类:NullPointerException 3 类型强制转换异常:ClassCastException 4 数组负下标异常:NegativeArrayException 5 数组下标越界异常:ArrayIndexOutOfBoundsException 6 违背安全原则异常:SecturityException 7 文件已结束异常:EOFException 8 文件未找到异常:FileNotFoundException 9 字符串转换为数字异常:NumberFormatException 10 操作数据库异常:SQLException 11 输入输出异常:IOException 12 违法访问错误:IllegalAccessError 13 内存不足错误:OutOfMemoryError 14 堆栈溢出错误:StackOverflowError 15.其他,请参考:https://www.cnblogs.com/cvst/p/5822373.html
3.2找出问题后的操作步骤:
1.找到是monkey里面的哪个地方出错
2.查看Monkey里面出错前的一些事件动作,并手动执行该动作
3.若以上步骤还不能找出,可以使用之前执行的monkey命令再执行一遍,注意seed值要一样。
4.日志导出
细心地小伙伴可能通过前边的一系列操作和查找日志定位问题,发现docs命令窗口在查看和操作的时候特别地不方便,那么Monkey有没有像Tomcat等其他工具那样有log日志文件,很不幸告诉小伙伴们答案是:NO!,但是好消息是:我们可以将日志导出到文件中。然后将文件导出到手机或者是电脑上。
4.1导出方法
导出到手机:
1 2 3 4 5 6 7 8 9 |
|
导出到电脑:
1 2 3 4 5 6 7 |
|
以上的导出方法,导出日志后,标准流和错误流的日志混合在一起,给我们定位和分析问题又带来麻烦了,因此需要将其分开导出保存。
标准流和错误流分开保存:
1 2 3 4 5 |
|
各个文件主要内容:
1 2 3 4 5 |
|
5.日志参数
1、-v 较少的日志信息
2、-v -v 较为丰富的日志信息
3、-v -v -v 最高级别的日志信息(推荐)
6.小结
初步分析方法:
(1)、找到是monkey里面的哪个地方出现错误
(2)、查看monkey里面出错前的一些事件动作,并手动执行该动作
(3)、若以上步骤还不能找到,可以使用之前执行monkey命令,再执行一遍,注意使用的seed值要一样
测试结果分析:
(1)、ANR问题(程序无响应):在日志中搜索“ANR"(application no response)
(2)、闪退问题:在日志中搜索"crash"
(3)、异常:搜索"exception"
(4)、强制退出:搜索"force closed"
好了,今天关于日志就到这里了!
【下面是我整理的2023年最全的软件测试工程师学习知识架构体系图】
一、Python编程入门到精通
二、接口自动化项目实战
三、Web自动化项目实战
![](https://img-blog.csdnimg.cn/af6acde5fef948688e853163e68085a3.png)
四、App自动化项目实战
五、一线大厂简历
![](https://img-blog.csdnimg.cn/da130899855e439f8d9f538e9d396b42.png)
六、测试开发DevOps体系
七、常用自动化测试工具
![](https://img-blog.csdnimg.cn/262b329562404406bcab732e5f680348.png)
八、JMeter性能测试
九、总结(尾部小惊喜)
生命不息,奋斗不止。每一份努力都不会被辜负,只要坚持不懈,终究会有回报。珍惜时间,追求梦想。不忘初心,砥砺前行。你的未来,由你掌握!
生命短暂,时间宝贵,我们无法预知未来会发生什么,但我们可以掌握当下。珍惜每一天,努力奋斗,让自己变得更加强大和优秀。坚定信念,执着追求,成功终将属于你!
只有不断地挑战自己,才能不断地超越自己。坚持追求梦想,勇敢前行,你就会发现奋斗的过程是如此美好而值得。相信自己,你一定可以做到!