zoukankan      html  css  js  c++  java
  • Monkey测试

    1. Monkey测试操作:

        1》 通过adb shell指令进入手机终端

        2》 输入 Monkey 1000 指令对手机进行1000次操作,做为一次压力测试。

    2. Monkey指令可用参数

       

    参数 含义
    -v  在控制台打印压力测试时的相关数据
    -p xx 对指定的包名应用进行压力测试
    -s xx 对指定种子的随机序列进行测试。能保证压力测试重现
    --throttle xx 压力测试时,每个随机事件间的时间间隔(毫秒)
    --pct-touch xx 压力测试过程中触摸事件所占比例
    --ignore-crashes 压力测试中出现崩溃,忽略并继续进行
    --ignore-timeouts 压力测试中出现超时,忽略并继续进行

    3. 自定义压力事件(需要书写MonkeyScript脚本)

      1。   monkey中提供的函数如下:

    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)  
    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)     
    4. DispatchFlip(boolean keyboardOpen)    
    5. DispatchPress(int keyCode)    
    6. LaunchActivity(String pkg_name, String cl_name)  
    7. UserWait(long sleeptime)    
    8. LongPress(int keyCode) 

          2. 例如:  

           type= user

           count= 49
           speed= 1.0
           start data >>
           LaunchActivity(com.example.android.notepad, com.example.android.notepad.NotesList)
           DispatchPress(KEYCODE_DPAD_DOWN)
           LongPress(KEYCODE_DOWN)
           DispatchPress(KEYCODE_BACK)

          其中 type值可以任意,源码中没有对该值做任何处理,count的设定也是无效的,所以前四行可以作为模板。

      

          3. 运行脚本

       monkey -f filename count  

    4. MonkeyRunner 进行测试(高级)

       MonkeyRunner分为三个模块: MonkeyRunner、MonkeyDevice、MonkeyImage

        1. 编写python脚本  

               2. 使用monkeyrunner filename   运行脚本

               使用参考:http://blog.csdn.net/mad1989/article/details/38087737

  • 相关阅读:
    Javascript 严格模式详解
    SeaJS与RequireJS最大的区别
    AMD 和 CMD 的区别有哪些?
    JS 关于(function( window, undefined ) {})(window)写法的理解
    高性能 CSS3 动画
    js对象私有变量公有变量问题
    探讨js字符串数组拼接的性能问题
    提高 DHTML 页面性能
    vue请求本地json数据
    vuejs绑定img 的src
  • 原文地址:https://www.cnblogs.com/android-er/p/6035146.html
Copyright © 2011-2022 走看看