1,Monkey的初识和使用

一,基本用法:
Monkey命令是通过adb shell 命令行的方式来实施运行的;

   基本的语法格式:
    adb  shell  monkey  [options]  

    adb  shell  -help 
    monkey: [-p  ALLOWED_PACKAGE    [-p ALLOWED_PACKAGE]   ... ]
                   [-v [-v] ...]  
                   [-s SEED]
                   [--pct-touch  PERCENT] 
                   [--pct-motion PERCENT]
                   [--pct-trackball PERCENT]
                   [--pct-syskeys PERCENT]
                   [--pct-nav PERCENT]
                   [--pct-majornav PERCENT]
                   [--pct-appswitch PERCENT]
                   [--pct-anyevent PERCENT]
                   [--ignore-crashes]
                   [--ignore-timeouts]
                   [--ignore-security-exceptions]
                   [--throttle MILLISEC ]
                   [--kill-process-after-error]
                   [--monitor-native-crashes]
                   [--ignore-native-crashes]


                   [--pct-flip PERCENT]
                   [--pct-pinchzoom PERCENT]
                   [-c MAIN_CATEGORY [-MAIN_CATEGORY] ...]
                   [--hprof]
                   [--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]
                   [--pkg-whitelist-file PACKAGE_WHITELIST_FILE]
                   [--wait-dbg]
                   [--dbg-no-events]
                   [--setup scriptfile] [-f scriptfile [-f scriptfile] ...]
                   [--port port]
                   [--randmize--throttle]
                   [--profile-wait MILLISEC]
                   [-device-sleep-time MILLISEC]
                   [--randomize-script]
                   [--script-log]
                   [-bugreport]
                   [--periodic-bugreport]
                   count

三、可选参数解释
1,参数:-p
指定要测试应用程序的包名,可以指定一个,也可以指定多个。
意思是:指定后,系统只允许monkey启动指定的一个或多个APP, 否则
系统会允许monkey启动所有的APP
例子:
adb shell monkey -p com.example.movingdetect 20

            2,参数: -v
             输入日志的详细等级:
             -v   输出的日志最少
             -v -v 
             -v -v -v  输出的日志最多,最详细
            例子:
            adb shell monkey -p com.example.movingdetect -v -v -v   20
     
           3,参数:-s  seed
                 记录在monkey测试中,测试事件的类型、顺序和用时,
                  如果还想再执行一次 同样的monkey测试,那么就可以
                 将seed指 设定为 上次monkey测试,设定的值;

             例子:
             adb shell monkey -p com.example.movingdetect -v -v -v -s 100   20

           4,参数:--pct-touch percent
                 触摸事件百分比
                例子:
               adb shell 
               monkey -p com.example.movingdetect -v -v -v -s 100  --pct-touch 50  20

          5,--pct-motion   percent 
                 动作事件百分比
                 例子:
                adb shell 
             monkey -p com.example.movingdetect -v -v -v -s 100  --pct-motion 50  20
           
        6, --pct-trackball  percent
               轨迹事件百分比
               例子:
               adb shell 

monkey -p com.example.movingdetect -v -v -v -s 100 --pct-trackball 50 20

         7,--pct-syskeys percent 
            按系统按键事件百分比 
             系统按键:home,back,menu, v+,v-
            例子:
            adb shell 
        monkey -p com.example.movingdetect -v -v -v -s 100  --pct-syskeys 50  20
              
          8,--pct-nav  percent
              按基本导航按键事件的百分比
               基本导航事件:right,up ,down,left
          例子:
           adb shell 
        monkey -p com.example.movingdetect -v -v -v -s 100  --pct-nav 50  20

           9,--pct-majornav  percent 
              按图形界面的按键的百分比
            例子:
          adb shell 
        monkey -p com.example.movingdetect -v -v -v -s 100  --pct-majornav 50  20

           10,--pct-appswitch  percent
               启动 Activity的百分比
               例子:
           adb shell 
       monkey -p com.example.movingdetect -v -v -v -s 100  --pct-appswitch 50  20

           11,--pct-anyevent  percent
              其他类型事件的百分比
                例子:
            adb shell
        monkey -p com.example.movingdetect -v -v -v -s 100  --pct-anyevent 50  20
            
            12,--ignore-crashes 
                 忽略崩溃和异常
              adb shell monkey -p com.example.movingdetct -v-v-v  -s 100
               --ignore-crashes  20
             
            13,--ignore-timeouts 
                 忽略超时
                  adb shell 
             monkey -p com.example.movingdetect -v -v -v -s 100
              --ignore-timeouts 20
            
                14,-ignore-security-exceptions 
                    忽略许可错误(如 证书许可,网络许可)
                    adb shell
                monkey -p  com.lyt.demo06 -v -v -v  -s 100  
                 --ignore-security-exceptions   20
            
                15,--throttle    
                     延迟执行时间
                 adb shell
                 monkeyy -p com.lyt.demo06 -v -v -v -s 100
                  --throttle  1000  20
          
                16,--kill-process-after-error
                     应用程序发生错误的时候,monkey停止运行 ,保留在
                   当前状态 
                例子:
                adb shell
                monkey -p com.example.movingdetect -v -v -v -s 100 
                --throttle 1000 --kill-process-after-error    20

                 17,--monitor-native-crashes
                       监听本地崩溃
                  adb shell
                 monkey -p com.demo06 -v -v -v -s 100
                 -monitor-native-crashes   20

三,Monkey测试结果的分析方法:

你可能感兴趣的:(1,Monkey的初识和使用)