标签:
Monkey是Android中的一个命令行工具,可以运行在模拟器里或实际设备中。它向系统发送伪随机的用户事件流(如按键输入、触摸屏输入、手势输入等),实现对正在开发的应用程序进行压力测试。Monkey测试是一种为了测试软件的稳定性、健壮性的快速有效的方法。
最近在测试公司手机软件app,抽空研究了下手机自动压力测试-monkey,如下:
步骤1:电脑环境准备:搭建android 开发环境
步骤2:手机环境准备:安装待测试的apk
步骤3:打开cmd,进入adb shell,命令如下:
C:\Users\chenshan>adb shell shell@hwG750-T20:/ $ monkey -p cn.emoney.acg -v 500
说明:-p :指定被测试apk,主Activity(第一个启动的Activity)所在的包名(我问的开发)
-v :指定测试的次数
运行结果如下:
monkey -p cn.emoney.acg -v 500 :Monkey: seed=1423954039925 count=500 :AllowPackage: cn.emoney.acg :IncludeCategory: android.intent.category.LAUNCHER :IncludeCategory: android.intent.category.MONKEY // Event percentages: // 0: 15.0% // 1: 10.0% // 2: 2.0% // 3: 15.0% // 4: -0.0% // 5: 25.0% // 6: 15.0% // 7: 2.0% // 8: 2.0% // 9: 1.0% // 10: 13.0% :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ ory.LAUNCHER;launchFlags=0x10200000;component=cn.emoney.acg/.SecurityHome;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in tent.category.LAUNCHER] cmp=cn.emoney.acg/.SecurityHome } in package cn.emoney.a cg :Sending Touch (ACTION_DOWN): 0:(636.0,1832.0) :Sending Touch (ACTION_UP): 0:(614.0191,1819.9386) :Sending Touch (ACTION_DOWN): 0:(430.0,1614.0) :Sending Touch (ACTION_UP): 0:(504.59412,1667.4562) :Sending Touch (ACTION_DOWN): 0:(788.0,534.0) :Sending Touch (ACTION_UP): 0:(780.03546,539.9423) :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ ory.LAUNCHER;launchFlags=0x10200000;component=cn.emoney.acg/.SecurityHome;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in tent.category.LAUNCHER] cmp=cn.emoney.acg/.SecurityHome } in package cn.emoney.a cg :Sending Trackball (ACTION_MOVE): 0:(-3.0,-2.0) :Sending Touch (ACTION_DOWN): 0:(353.0,238.0) :Sending Touch (ACTION_UP): 0:(356.59268,215.40685) :Sending Trackball (ACTION_MOVE): 0:(2.0,-1.0) :Sending Trackball (ACTION_MOVE): 0:(-2.0,4.0) :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ ory.LAUNCHER;launchFlags=0x10200000;component=cn.emoney.acg/.SecurityHome;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in tent.category.LAUNCHER] cmp=cn.emoney.acg/.SecurityHome } in package cn.emoney.a cg :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ ory.LAUNCHER;launchFlags=0x10200000;component=cn.emoney.acg/.SecurityHome;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in tent.category.LAUNCHER] cmp=cn.emoney.acg/.SecurityHome } in package cn.emoney.a cg :Sending Trackball (ACTION_MOVE): 0:(-3.0,-5.0) :Sending Trackball (ACTION_MOVE): 0:(-5.0,3.0) :Sending Touch (ACTION_DOWN): 0:(601.0,152.0) :Sending Touch (ACTION_UP): 0:(602.1031,156.88362) :Sending Touch (ACTION_DOWN): 0:(293.0,175.0) //[calendar_time:2015-02-02 16:12:45.307 system_uptime:115853036] // Sending event #100 :Sending Touch (ACTION_UP): 0:(291.35492,141.05412) :Sending Touch (ACTION_DOWN): 0:(243.0,1537.0) :Sending Touch (ACTION_UP): 0:(251.39348,1530.0) :Sending Trackball (ACTION_MOVE): 0:(2.0,-5.0) :Sending Touch (ACTION_DOWN): 0:(616.0,1098.0) :Sending Touch (ACTION_UP): 0:(623.84454,1098.5345) :Sending Touch (ACTION_DOWN): 0:(190.0,98.0) :Sending Touch (ACTION_UP): 0:(188.01633,81.4052) :Sending Touch (ACTION_DOWN): 0:(643.0,310.0) :Sending Touch (ACTION_UP): 0:(643.3258,323.91415) :Sending Touch (ACTION_DOWN): 0:(83.0,355.0) :Sending Touch (ACTION_UP): 0:(86.26117,355.42242) :Sending Trackball (ACTION_MOVE): 0:(-4.0,3.0) :Sending Touch (ACTION_DOWN): 0:(399.0,398.0) :Sending Touch (ACTION_UP): 0:(425.0628,350.23315) :Sending Touch (ACTION_DOWN): 0:(26.0,1817.0) :Sending Touch (ACTION_UP): 0:(6.7867804,1804.3572) :Sending Touch (ACTION_DOWN): 0:(562.0,1905.0) :Sending Touch (ACTION_UP): 0:(560.2228,1905.0571) :Sending Trackball (ACTION_MOVE): 0:(-1.0,-1.0) :Sending Touch (ACTION_DOWN): 0:(11.0,872.0) :Sending Touch (ACTION_UP): 0:(0.0,856.52124) :Sending Trackball (ACTION_MOVE): 0:(-4.0,1.0) //[calendar_time:2015-02-02 16:12:45.498 system_uptime:115853191] // Sending event #200 :Sending Touch (ACTION_DOWN): 0:(26.0,1246.0) :Sending Touch (ACTION_UP): 0:(30.53358,1232.7083) :Sending Touch (ACTION_DOWN): 0:(92.0,761.0) :Sending Touch (ACTION_UP): 0:(70.751976,747.7252) :Sending Touch (ACTION_DOWN): 0:(590.0,178.0) :Sending Touch (ACTION_UP): 0:(629.8198,216.51576) :Sending Touch (ACTION_DOWN): 0:(481.0,1223.0) :Sending Touch (ACTION_UP): 0:(459.6905,1218.851) :Sending Trackball (ACTION_MOVE): 0:(3.0,-4.0) :Sending Touch (ACTION_DOWN): 0:(559.0,566.0) :Sending Touch (ACTION_UP): 0:(573.4749,652.7251) :Sending Trackball (ACTION_MOVE): 0:(0.0,-5.0) :Sending Touch (ACTION_DOWN): 0:(817.0,221.0) :Sending Touch (ACTION_UP): 0:(783.61285,232.48059) :Sending Trackball (ACTION_MOVE): 0:(-1.0,-5.0) :Sending Trackball (ACTION_UP): 0:(0.0,0.0) //[calendar_time:2015-02-02 16:12:45.673 system_uptime:115853367] // Sending event #300 //[calendar_time:2015-02-02 16:12:45.674 system_uptime:115853368] // Sending event #300 :Sending Trackball (ACTION_MOVE): 0:(-1.0,-5.0) :Sending Trackball (ACTION_MOVE): 0:(-3.0,4.0) :Sending Touch (ACTION_DOWN): 0:(877.0,1410.0) :Sending Touch (ACTION_UP): 0:(804.5438,1399.0889) :Sending Touch (ACTION_DOWN): 0:(325.0,90.0) :Sending Touch (ACTION_UP): 0:(251.87192,0.0) :Sending Touch (ACTION_DOWN): 0:(468.0,1280.0) :Sending Touch (ACTION_UP): 0:(459.7335,1275.3344) :Sending Trackball (ACTION_MOVE): 0:(-5.0,-1.0) :Sending Touch (ACTION_DOWN): 0:(517.0,1616.0) :Sending Touch (ACTION_UP): 0:(514.9753,1622.0171) :Sending Trackball (ACTION_MOVE): 0:(0.0,-2.0) :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ ory.LAUNCHER;launchFlags=0x10200000;component=cn.emoney.acg/.SecurityHome;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in tent.category.LAUNCHER] cmp=cn.emoney.acg/.SecurityHome } in package cn.emoney.a cg :Sending Touch (ACTION_DOWN): 0:(57.0,1822.0) :Sending Touch (ACTION_UP): 0:(65.71579,1833.4447) :Sending Trackball (ACTION_MOVE): 0:(-2.0,-1.0) :Sending Trackball (ACTION_UP): 0:(0.0,0.0) :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ ory.LAUNCHER;launchFlags=0x10200000;component=cn.emoney.acg/.SecurityHome;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in tent.category.LAUNCHER] cmp=cn.emoney.acg/.SecurityHome } in package cn.emoney.a cg :Sending Trackball (ACTION_MOVE): 0:(2.0,-5.0) //[calendar_time:2015-02-02 16:12:45.942 system_uptime:115853636] // Sending event #400 :Sending Touch (ACTION_DOWN): 0:(371.0,456.0) :Sending Touch (ACTION_UP): 0:(322.275,343.40207) :Sending Touch (ACTION_DOWN): 0:(869.0,778.0) :Sending Touch (ACTION_UP): 0:(851.1657,778.8365) :Sending Trackball (ACTION_MOVE): 0:(-3.0,-1.0) :Sending Touch (ACTION_DOWN): 0:(1073.0,1322.0) :Sending Touch (ACTION_UP): 0:(1077.2527,1313.2167) :Sending Touch (ACTION_DOWN): 0:(499.0,1342.0) :Sending Touch (ACTION_UP): 0:(467.50674,1373.2031) :Sending Trackball (ACTION_MOVE): 0:(1.0,3.0) :Sending Trackball (ACTION_MOVE): 0:(1.0,-1.0) :Sending Touch (ACTION_DOWN): 0:(449.0,157.0) :Sending Touch (ACTION_UP): 0:(442.57257,163.57645) :Sending Trackball (ACTION_MOVE): 0:(-2.0,0.0) :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ ory.LAUNCHER;launchFlags=0x10200000;component=cn.emoney.acg/.SecurityHome;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in tent.category.LAUNCHER] cmp=cn.emoney.acg/.SecurityHome } in package cn.emoney.a cg :Sending Trackball (ACTION_MOVE): 0:(-2.0,4.0) Events injected: 500 :Sending rotation degree=0, persist=false :Dropped: keys=124 pointers=369 trackballs=0 flips=0 rotations=0 ## Network stats: elapsed time=1037ms (0ms mobile, 1037ms wifi, 0ms not connecte d) // Monkey finished
标签:
原文地址:http://www.cnblogs.com/nzyjlr/p/4268087.html