monkey随机自动化测试应用

1、monkey -p apk包名 -v 300 打印基本日志 Level 0

 

2、monkey -p apk包名 -v -v 300 打印基本日志 Level 1

 

3、monkey -p apk包名 -v -v -v 300 打印基本日志 Level 2

 

4、monkey -p apk包名 –throttle 500 50 用户事件之间的延时操作,表示0.5s每次

 

5、monkey 随机测试 假设随机测试过程中发现了bug,程序崩溃,报告给了开发,开发说修复好了,如何进行回归?

  5.1、monkey 推出了 -s 选项 1—10组(注意:把软件置为初始状态)

  5.2、monkey -p apk包名 –throttle 500 -s 4 100(伪随机)

 

  5.3、monkey -p 包名 –throttle 300 -s 6 --ignore-crashes --ignore-timeouts –ignore-security-exception 1000  让monkey长久地执行下去,执行到设定次数为止

    5.3.1、monkey -p com.skoda.sc.mos --throttle 300 -s 6 --ignore-crashes 1000

       --ignore-crashes应用崩溃时,monkey不停止运行

    5.3.2、monkey -p com.skoda.sc.mos --throttle 300 -s 6 --ignore-crashes --ignore-timeouts  1000

      --ignore-timeouts应用发生ANR错误时,monkey不停止运行

    5.3.3、monkey -p com.skoda.sc.mos --throttle 300 -s 6 --ignore-crashes --ignore-timeouts --ignore-security-exceptions 1000

      --ignore-security-exceptions应用发生许可错误(如:证书许可、网络许可)时,monkey不停止运行

6、用户事件流应该是设置在10亿以内

  6.1、monkey如何使用:白天/晚上 开着monkey 开一个晚上

  6.2、会出现一个问题 18:00 如果出现app崩溃,monkey默认会停止运行

 

7、--pct-事件类别:设置用户事件流所占的百分比

  7.1、用户反馈:公司的APP在旋转屏幕的时候偶然出现闪退 monkey指定用户事件流

  7.2monkey -p 包名 –throttle 300(时间间隔) -s 6 –pct-rotation(旋转操作) 100(百分比) 300(次数)

  7.3monkey -p com.skoda.sc.mos --throttle 300 -s 6 --pct-rotation 100 300

 

8、monkey -p apk包名 –throttle 300 -s 6 –pct-rotation 30 –pct-touch 60 –pct-syskeys 10 300

  8.1、monkey -p com.skoda.sc.mos --throttle 300 -s 6 --pct-rotation 30 --pct-touch 60 --pct-syskeys 10 300

  备注:百分比不能超过100%

 

9、公司monkey应用实战步骤:

  9.1、adb logcat -c 清除日志缓存

  9.2、adb logcat -f 手机路径 -s *.E -v long

  9.3、日志打印:

    9.3.1、到电脑文件路径下:

      adb logcat >C:\Users\quan\Desktop\P12\login\log1.txt -s *:E -v long

    9.3.2、日志打印到手机真机文件路径下:

      adb logcat  手机/sdcard/文件路径

      adb logcat 电脑a.txt 手机路径/sdcard/Movies

    9.3.3、日志打印到手机模拟器文件路径下:

 

  9.4、编写monkey命令并执行(一般次数写最大、指定-s、--throttle   --ignore-crashes –ignore-timeouts  --ignore-security-exception)

    monkey -p com.skoda.sc.mos --throttle 300 -s 6 --ignore-crashes --ignore-timeouts --ignore-security-exceptions 1000

    throttle:压制、控制  ignore:忽略  crashes:崩溃  timeouts:超时  security:安全、证书  exceptions:异常

    monkey -p com.sky.jisuanji --throttle 300 -s 8 --ignore-crashes --ignore-timeouts --ignore-security-exceptions 3000

  9.5、到时间停止monkey(自动停止monkey==>python定时任务 18:00 22:00 杀掉monkey进程 os.system(“adb shell kill -9   pid”))

  9.6、停止日志  1、杀进程 2、ctrl+c

  9.7、把日志从手机下载到电脑 adb pull

  9.8、分析日志报错  查找包名  发现Exception

posted @ 2021-09-10 15:10  码·蚁  阅读(169)  评论(0编辑  收藏  举报