美文网首页
Monkey稳定性测试

Monkey稳定性测试

作者: circle_hyy | 来源:发表于2018-10-21 14:50 被阅读0次

    一、目的
    测试app的稳定性、健壮性

    二、说明
    【例子】
    adb shell monkey -p com.android.calendar 1000 向日历app发动1000次随机事件
    【-v】日志级别
    adb shell monkey -v -p com.android.calendar 1000
    adb shell monkey -v-v -p com.android.calendar 1000
    adb shell monkey -v-v-v -p com.android.calendar 1000
    【-s】随机种子
    adb shell monkey -p com.android.calendar -s 2017 1000
    【-p】指定包名(可以多个)
    查看已安装的包:
    1)adb shell
    su root
    cd data
    cd data
    2)adb shell pm list packages
    【--throttle】事件间隔
    adb shell monkey -p com.android.calendar --throttle 3000 1000
    【--pct-touch<percent>】触屏事件的比例
    【--pct-motion<percent>】滑动事件的比例
    【--pct-trackball<percent>】轨迹球事件的比例
    【--pct-nav<percent>】导航事件的比例
    【--pct-majornav<percent>】主要导航事件如back键、menu键的比例
    【--pct-syskeys<percent>】系统按键事件拨号、挂断、音量控制等的比例
    【--pct-appswitch<percent>】启动活动事件的比例
    【--pct-anyevent<percent>】普通按键消息、不常用的设备按钮事件的比例
    【--hprof】在发送事件序列的前后生成性能分析报告 /data/misc目录下
    【--ignore-crashes】忽略应用崩溃
    【--ignore-timeout】忽略超时错误
    【--ignore-security-exceptions】忽略证书或网络许可错误
    【--kill-process-after-error】停止发生错误的进程
    【--monitor-native-crashes】本地代码崩溃时系统停止运行
    【--wait-dbg】启动后等待调试器与其连接

    三、使用
    1、向一个坐标点发送手势信息
    DispatchPointer(long downTime,long eventTime,int action,float x,float y,float pressure,float size,int metaState,float xPrecision,float yPrecision,int device,int edgeFlags)
    action 0按下 1抬起 2移动
    输入手势密码“1-2-3”
    DispatchPointer(0,0,0,155,476,0,0,0,0,0,0,0)
    DispatchPointer(0,0,2,155,476,0,0,0,0,0,0,0)
    DispatchPointer(0,0,0,357,474,0,0,0,0,0,0,0)
    DispatchPointer(0,0,2,357,474,0,0,0,0,0,0,0)
    DispatchPointer(0,0,0,547,485,0,0,0,0,0,0,0)
    DispatchPointer(0,0,2,547,485,0,0,0,0,0,0,0)
    DispatchPointer(0,0,1,547,485,0,0,0,0,0,0,0)
    2、向一个坐标点发送跟踪求信息
    DispatchTrackball(long downTime,long eventTime,int action,float x,float y,float pressure,float size,int metaState,float xPrecision,float yPrecision,int device,int edgeFlags)
    3、发送按键消息
    DispatchKey(long downTime,long eventTime,int action,int code,int repeat,int metaState,int device,int scancode)
    输入("Abc")
    DispatchKey(0,0,0,29,0,0,0,0)
    DispatchKey(0,0,1,29,0,0,0,0)
    DispatchKey(0,0,0,30,0,0,0,0)
    DispatchKey(0,0,1,30,0,0,0,0)
    DispatchKey(0,0,0,31,0,0,0,0)
    DispatchKey(0,0,1,31,0,0,0,0)
    4、打开或关闭软键盘
    DispatchFlip(boolean keyboardOpen)
    为true时打开软键盘,为false时关闭软键盘
    5、启动任意活动界面
    LaunchActivity(String pkg_name,String cl_name)
    LaunchActivity(com.yuy.test,com.yuy.test.MainActivity)
    6、运行测试用例
    LaunchInstrumentation(test_name,runner_name)
    test_name测试用例名
    runner_name测试用例类名
    7、让脚本中断一段时间
    UserWait(long sleeptime)
    毫秒
    8、在设备运行shell命令
    RunCmd(cmd)
    9、模拟手指单击事件
    Tap(x,y,tarDuration)
    Tap(100,100,3000)
    10、等待5秒
    ProfileWait()
    11、唤醒设备并解锁
    DeviceWakeUp()
    12、向Shell输入一个字符串
    DispatchString(input)
    DispatchString(hello)

    相关文章

      网友评论

          本文标题:Monkey稳定性测试

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