Monkey基本命令

–adb monkey测试相关命令介绍:——–

  • 1,adb install xx.apk:把指定的安装包apk文件安装到测试设备中
  • 2,adb shell monkey :给指定的设备发送压力测试,number是要测试的次数。执行这个命令的效果就相当于有个手指在你的手机上乱点。我尝试了10000次,结果费了好一会儿功夫才把手机恢复到我想到的效果。
  • 3,adb shell monkey -p pkgname :同上面效果一样,只是对指定包名(pkgname)apk进行测试。
  • 4,Monkey高级参数的应用 
    4.1.throttle参数:指定事件之间的间隔时间 
    adb shell monkey -throttle :milliseconds是时间值 ,单位毫秒 
    4.2.seed参数:伪随机数生成器的seed 值。 
    adb shell monkey -s :如果用相同的 seed 值再次运行 Monkey ,它将生成相同的事件序列。 
    4.3.touch:设置触摸事件 
    adb shell monkey -pct-touch :指定touch事件的百分比percent 
    4.4.motion:设置动作事件 
    adb shell monkey -pct-motion :指定motion事件的百分比percent 
    4.5.trackball:设置轨迹球事件 
    adb shell monkey -pct-trackball :指定轨迹球事件百分比percent 
    4.6.nav:导航事件设置 
    adb shell monkey -pct-nav :指定基本导航事件百分比percent 
    4.7.majornav:设置主要导航事件 
    adb shell monkey -pct-majornav :设定主要导航事件百分比percent,兼容中间键,返回键,菜单按键 
    4.8.syskeys:设置事件 
    adb shell monkey -pct-syskeys :设定系统事件百分比percent,比如HOME,BACK,拨号及音量调节等事件。 
    4.9.appswitch:启动Activity事件 
    adb shell monkey -pct-appswitch :设定启动activity的事件百分比percent 
    4.10.anyevent:不常用事件设置 
    adb shell monkey -pct-anyevent :设定不常用事件地百分比 
    4.11.crashes :程序崩溃事件设置 
    adb shell monkey -ignore-crashes :忽略崩溃和异常事件 
    4.12.timeouts:超时事件设置 
    adb shell monkey -ignore-timeouts :忽略超时事件 
    介绍了一些常用设置后,开始基本地Monkey之旅: 
    第一步:准备测试apk,如下图是我要进行测试的APK,放置在我的电脑D盘: 
    这里写图片描述

第二步:把测试设备(手机)与电脑保持连接,这个就不截图啦。 
第三步:使用adb install 命令把要测试的apk安装到手机,当然你可以直接测试已经安装在手机上的apk。 
这里写图片描述 
第四步:使用上面的基本测试命令对安装好的monkey_test.apk进行Monkey测试。 
adb shell monkey -p com.xx.xx 10 指测试10次,截图如下,运行期间你可以看到手机上apk被操作。 
这里写图片描述 
第五步,根据自己的需要,使用其它命令对apk进行测试: 
比如通过adb shell monkey -v -p com.xx.xx 100来简单输出测试信息,如图 
这里写图片描述 
上面的百分比就是相应事件所占的比,还有其它诸如TOUCH事件等相关信息。 
其它的测试命令就不贴了,工作中自己想怎么测试就使用相关的命令就可以。 

猜你喜欢

转载自blog.csdn.net/qq_40857831/article/details/80726573