美文网首页
monkey02--高级参数

monkey02--高级参数

作者: JOooo_ | 来源:发表于2018-04-03 15:45 被阅读22次

    Monkey高级参数

    1. throttle:指定事件之间的间隔

    adb shell monkey --throttle <milliseconds>

    例:adb shell monkey -p com.android.calculator --throttle 1000 100

    monkey跑100个事件,每个事件间隔1秒

    2. seed:指定随机生成树的seed值(随机操作的序列)

    如果两次monkey随机的seed值一样,则随机操作的序列是一致的。

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

    例:adb shell monkey -p com.android.calculator -s 100 50(seed值是100)

    3. 触摸事件:设定触摸事件百分比

    adb shell monkey --pct-touch <percent>

    例:adb shell monkey -p com.android.calculator --pct-touch 100 100

    例:adb shell monkey -v -p com.android.calculator --pct-touch 100 100

    -v 执行时显示事件类型等信息

    4. 动作事件:设定动作事件百分比

    adb shell monkey --pct-motion <percent>

    轨迹球事件: --pct-trackball

    基本导航事件: --pct-nav(输入设备的上下左右)

    主要导航事件:--pct-majornav (兼容中间键,返回键,菜单按键)

    系统导航事件:--pct-syskeys (手机硬件相关,HOME,BACK,拨号及音量键)

    启动Activity事件:--pct-appswitch (在app之间切换)

    不常用事件:--pct-anyevent (除以上主要事件之外的事件)

    5. 崩溃事件:忽略崩溃和异常

    有时app跑monkey出现崩溃,会停止运行。这时需要设置忽略崩溃和异常event跑完。

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

    6. 超时事件:忽略超时事件ANR

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

    7. CRASH/ANR结果析取

    当运行app出现崩溃时,终端会出现以下日志,在event445时发生崩溃,并给出seed值。

    当重新monkey运行使用该seed值时会重现这次crash。

    image.png

    日志中可以看到CRASH开头的CRASH日志。

    image.png

    ANR的结果析取与CRASH类似。可以在日志中找到ANR的信息。

    image.png

    如果自己手动点击的时候出现ANR,则可以使用以下方式查看日志

    image.png

    adb shell进入手机

    进入data/anr目录,查看traces.txt信息

    相关文章

      网友评论

          本文标题:monkey02--高级参数

          本文链接:https://www.haomeiwen.com/subject/alqchftx.html