首页 > 其他 > 详细

自动化测试之Monkey事件

时间:2020-06-16 21:47:49      阅读:52      评论:0      收藏:0      [点我收藏+]

Monkey事件

一、Monkey参数

(1)帮助类参数

  monkey -h

(2)日志级别

  adb shell monkey -v -v -v 随机事件数(-v表示日志信息级别,越多越详细)

技术分享图片

(3)事件类参数

  1)执行指定的脚本

  adb  shell  monkey  -f  <scriptfile>  <event-count>

  eg:  adb   shell  monkey  -f  /mnt/sdcard/test1

  2)伪随机数生成种子值

  使用-s命令可以重复执行之前的伪随机操作,本身每次执行伪随机事件操作也会默认生成一个seed值

  adb  shell  moneky  -s  <seed>  <event -count>

  eg:  adb  shell  monkey  -s  666 100

       技术分享图片

  3)设置间隔如果你希望在每个命令之间加上固定的间隔时间,可以用  --throttle(注意前面是)命令。(想要打印日志文件就加-v)

   adb  shell   monkey  --throttle  <milliseconds>

     eg:adb  shell  monkey  --throttle  1000  100

    技术分享图片

 

 

 (4)调整触摸事件百分比(0:触摸事件;1:手势事件..)

  如果你希望调整触摸事件的百分比,记住使用 --pct-touch

  adb  shell  monkey  --pct-touch

  eg:adb  shell  monkey  --pcy-touch  30(触摸事件变成30%)  200

  <precent>--pct-touch:后面接触摸事件百分比

       技术分享图片 

(5)调整手势事件百分比

  adb  shell  monkey  --pct-motion

  eg:adb  shell  monkey  -v -v  --pct-motion 40(手势事件变成40%)  200

     技术分享图片

  同时调整手势触摸事件

  技术分享图片

(6)调整应用启动事件百分比(8)

  如果你希望应用启动事件的百分比,记住使用--pct-appswitch

  adb  shell  monkey  --pct-appswitch <precent>

  eg:adb  shell  monkey  -v  --pct-appswitch

  --pct-appswitch:后面接应用事件百分比

  应用启动事件(即activity launches)俗称打开应用,通过调整startActivity()方法最大限度地开启package下的所有应用

(7)约束类参数

  ①包约束

  -p:后面接一个或多个包名(<allowed-package-name>),如果应用需要访问其他包里的Activity,那相关的包也需要在此同时指定,如果不指定任何包

  monkey将允许系统启动全部包里的Activity

    adb  shell  monkey  -p  <allowed-package-name>  <event-count>

    eg:adb  shell  monkey  -p  com.ss.android.ugc.aweme  500

    两个Activity:adb  shell  monkey  -p  com.ss.android.ugc.aweme  -p  com.tencent.mm  500

       技术分享图片

 

 

  ②activity类约束

  如果你希望将monkey限制在一个或者几个类别中,使用以下命令:

  adb  shell  monkey  -c  <main-category>  <event-count>

  以下命令表示进行Intent.CATEGORY_LAUNCHER类别的Activity并发送1000个随机事件

  adb  shell  monkey  -c  Intent.CATEGORY_LAUNCHER  1000

(8)调试类参数

  ①应用程序崩溃后继续发送事件

  如果你希望monkey在应用程序崩溃后继续发送事件,则用--ignore-crashes命令

  adb  shell  monkey  --ignore-crashes  <event-count>

  在设置此选项后,当应用程序崩溃时,monkey将继续运行到计数完成,如果不设置,则可能异常停止

  ②超时错误继续发送事件

  如果你希望monkey在任何超时错误后继续发送事件,则需要用到 --ignore-timeouts指令

  adb  shell  monkey  --ignore-timeouts

  在设置此选项后,当程序发生超时错误时,monkey将继续完成

  ③应用程序权限错误发生后继续发送事件

  如果你希望monkey在程序错误发生后继续发送事件,则用--ignore-security-exceptions

  adb  shell  monkey  --ignore-security-exception

  在设置此选项后,程序出任何错误,monkey也会继续运行

  ④其他

      技术分享图片

 

自动化测试之Monkey事件

原文:https://www.cnblogs.com/Eliphaz/p/13145140.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!