Android 冒烟测试
安装配置monkey
使用monkey
- 查看adb 版本
adb version
- 查看当前可用设备
adb devices
- 查看monkey 帮助
adb shell monkey -help
- 执行1000此随机事件,不管是什么软件, COUNT 设置执行的次数
这里设置为1000
adb shell monkey 1000
- 指定某个APP,执行1000此随机事件,不管是什么软件, -p 指定被测应用的包名
adb shell monkey -p com.xdstock.app.andriod.client 1000
- -s 设置种子数(相当于设置一个路径,因为monkey是
随机事件,所以为了使回归路径一致就需要设置相同的seed值)
adb shell monkey 100 -s 5
如果想重现上面例子的路径下次执行的-s也必须为5
- --throttle 设置每次随机事件的时间间隔(单位:毫秒)
adb shell monkey 100 --throttle 500
如果想设置随机时间的时间间隔区间,可用使用 --throttle time --randomize-throttle
adb shell monkey 100 --throttle 500 --randomize-throttle
说明:执行一百次monkey随机事件,每次事件的间隔在0到500毫秒之间不固定
- -v 设置日志级别最多(默认一个-v)
adb shell monkey -v 100
如需更详细的日志可以加多个-v, 最多3个
adb shell monkey -v -v -v 100
- --ignore-crashes 运行中忽略crash,遇到crash依然把后面的事件跑完
adb shell monkey --ignore-crashes -v 100
- --ignore-timeouts 运行中忽略ANR,遇到ANR依然把后面的事件跑完
adb shell monkey --ignore-timeouts -v 100
- --ignore-native-crashes 忽略monkey本身的异常,直到事件执行完毕
adb shell monkey --ignore-native-crashes -v 100
- 设置事件百分比,所有的百分比加起来不能超过100%
<ol>
<li>触摸事件百分比,即参数--pct-touch</li>
<li>滑动事件百分比,即参数--pct-motion</li>
<li>缩放事件百分比,即参数--pct-pinchzoom</li>
<li>轨迹球事件百分比,即参数--pct-trackball</li>
<li>屏幕旋转事件百分比,即参数--pct-rotation</li>
<li>基本导航事件百分比,即参数--pct-nav</li>
<li>主要导航事件百分比,即参数--pct-majornav</li>
<li>系统事件百分比,即参数--pct-syskeys</li>
<li>Activity启动事件百分比,即参数--pct-appswitch</li>
<li>键盘翻转事件百分比,即参数--pct-flip</li>
<li>其他事件百分比,即参数--pct-anyevent</li>
</ol>
例如,设置点击事件占20%:
adb shell monkey --pct-touch 20 -v 100
- 运行并生成.txt的日志文件
adb shell monkey -p com.xxxx.xxx.xxx -v -v -v 1000 > Desktop/monkeytestOne.txt
monkey日志分析
zhenglian:~ tacker$ adb shell monkey -p com.xdstock.app.andriod.client -v 1000
:Monkey: seed=1484169407074 count=1000
:AllowPackage: com.xxx.xxx.xxx //---> 测试的包名
: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% //---> Activity 启动事件
// 9: 1.0% //---> 键盘翻转事件
// 10: 13.0% //---> 其他事件
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl } in package com.xdstock.app.andriod.client
:Sending Touch (ACTION_DOWN): 0:(626.0,215.0)
:Sending Touch (ACTION_UP): 0:(628.23285,221.56313)
:Sending Touch (ACTION_DOWN): 0:(347.0,773.0)
:Sending Touch (ACTION_UP): 0:(347.19254,770.814)
:Sending Touch (ACTION_DOWN): 0:(328.0,195.0)
:Sending Touch (ACTION_UP): 0:(321.54346,187.92857)
:Sending Touch (ACTION_DOWN): 0:(56.0,1187.0)
:Sending Touch (ACTION_UP): 0:(63.43934,1192.9033)
:Sending Touch (ACTION_DOWN): 0:(48.0,1080.0)
:Sending Touch (ACTION_UP): 0:(55.92652,1061.622)
:Sending Trackball (ACTION_MOVE): 0:(4.0,-1.0)
:Sending Touch (ACTION_DOWN): 0:(179.0,739.0)
:Sending Touch (ACTION_UP): 0:(175.34604,741.4012)
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl } in package com.xdstock.app.andriod.client
:Sending Trackball (ACTION_MOVE): 0:(-5.0,4.0)
:Sending Touch (ACTION_DOWN): 0:(306.0,683.0)
:Sending Touch (ACTION_UP): 0:(298.94794,663.2318)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-2.0)
:Sending Touch (ACTION_DOWN): 0:(691.0,1147.0)
:Sending Touch (ACTION_UP): 0:(682.62244,1130.4384)
:Sending Touch (ACTION_DOWN): 0:(420.0,1209.0)
:Sending Touch (ACTION_UP): 0:(412.41544,1202.9391)
:Sending Trackball (ACTION_MOVE): 0:(3.0,-2.0)
:Sending Touch (ACTION_DOWN): 0:(711.0,985.0)
:Sending Touch (ACTION_UP): 0:(704.8758,984.45935)
Can't open carrierweekinfo-conf.xml
//[calendar_time:2016-12-30 10:07:35.078 system_uptime:327922193]
// Sending event #100
//[calendar_time:2016-12-30 10:07:35.162 system_uptime:327922194]
// Sending event #100
:Sending Trackball (ACTION_MOVE): 0:(-2.0,0.0)
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl } in package com.xdstock.app.andriod.client
:Sending Trackball (ACTION_MOVE): 0:(3.0,-4.0)
:Sending Touch (ACTION_DOWN): 0:(47.0,1131.0)
:Sending Touch (ACTION_UP): 0:(109.77768,1186.3334)
:Sending Trackball (ACTION_MOVE): 0:(-1.0,0.0)
:Sending Trackball (ACTION_MOVE): 0:(0.0,4.0)
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
:Sending Touch (ACTION_DOWN): 0:(396.0,1229.0)
:Sending Touch (ACTION_UP): 0:(407.49582,1226.1687)
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl } in package com.xdstock.app.andriod.client
:Sending Touch (ACTION_DOWN): 0:(290.0,502.0)
:Sending Touch (ACTION_UP): 0:(234.55066,445.36554)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-4.0)
//[calendar_time:2016-12-30 10:07:35.397 system_uptime:327922430]
// Sending event #200
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-2.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-4.0)
:Sending Touch (ACTION_DOWN): 0:(681.0,650.0)
:Sending Touch (ACTION_UP): 0:(678.16254,653.8383)
:Sending Touch (ACTION_DOWN): 0:(57.0,121.0)
:Sending Touch (ACTION_UP): 0:(17.847889,25.810427)
// activityResuming(com.xdstock.app.andriod.client)
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl } in package com.xdstock.app.andriod.client
:Sending Trackball (ACTION_MOVE): 0:(3.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(1.0,-3.0)
:Sending Touch (ACTION_DOWN): 0:(235.0,79.0)
:Sending Touch (ACTION_UP): 0:(234.88528,79.73482)
// Allowing start of Intent { cmp=com.xdstock.app.andriod.client/.home.view.impl.HomeSearchMSPViewImpl } in package com.xdstock.app.andriod.client
:Sending Touch (ACTION_DOWN): 0:(208.0,783.0)
:Sending Touch (ACTION_UP): 0:(220.73349,773.8958)
:Sending Touch (ACTION_DOWN): 0:(364.0,1156.0)
:Sending Touch (ACTION_UP): 0:(370.3684,1145.2845)
:Sending Touch (ACTION_DOWN): 0:(23.0,486.0)
:Sending Touch (ACTION_UP): 0:(21.318256,508.3691)
:Sending Trackball (ACTION_MOVE): 0:(2.0,3.0)
//[calendar_time:2016-12-30 10:07:36.357 system_uptime:327923390]
// Sending event #300
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
:Sending Flip keyboardOpen=false
:Sending Touch (ACTION_DOWN): 0:(689.0,1073.0)
:Sending Touch (ACTION_UP): 0:(689.0984,1076.385)
// activityResuming(com.xdstock.app.andriod.client)
:Sending Touch (ACTION_DOWN): 0:(656.0,444.0)
:Sending Touch (ACTION_UP): 0:(657.84174,444.96918)
:Sending Touch (ACTION_DOWN): 0:(308.0,1194.0)
:Sending Touch (ACTION_UP): 0:(284.70468,1198.6243)
:Sending Touch (ACTION_DOWN): 0:(329.0,384.0)
:Sending Touch (ACTION_UP): 0:(327.12775,369.02747)
:Sending Touch (ACTION_DOWN): 0:(639.0,977.0)
:Sending Touch (ACTION_UP): 0:(720.0,889.2017)
:Sending Touch (ACTION_DOWN): 0:(152.0,698.0)
:Sending Touch (ACTION_UP): 0:(170.29561,686.3321)
:Sending Touch (ACTION_DOWN): 0:(215.0,974.0)
:Sending Touch (ACTION_UP): 0:(216.17403,974.9675)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,-2.0)
:Sending Touch (ACTION_DOWN): 0:(268.0,625.0)
:Sending Touch (ACTION_UP): 0:(273.2784,622.6929)
:Sending Touch (ACTION_DOWN): 0:(36.0,382.0)
:Sending Touch (ACTION_UP): 0:(31.11044,387.90247)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,-5.0)
:Sending Touch (ACTION_DOWN): 0:(526.0,803.0)
:Sending Touch (ACTION_UP): 0:(538.4675,807.8256)
//[calendar_time:2016-12-30 10:07:37.511 system_uptime:327924544]
// Sending event #400
//[calendar_time:2016-12-30 10:07:37.512 system_uptime:327924545]
// Sending event #400
:Sending Touch (ACTION_DOWN): 0:(711.0,1043.0)
:Sending Touch (ACTION_UP): 0:(658.15015,1004.91315)
// Rejecting start of Intent { act=android.intent.action.CALL_BUTTON cmp=com.android.contacts/.activities.PeopleActivity } in package com.android.contacts
:Sending Trackball (ACTION_MOVE): 0:(-2.0,2.0)
:Sending Touch (ACTION_DOWN): 0:(315.0,316.0)
:Sending Touch (ACTION_UP): 0:(315.43454,313.9006)
:Sending Touch (ACTION_DOWN): 0:(637.0,1212.0)
:Sending Touch (ACTION_UP): 0:(650.17126,1200.3177)
:Sending Touch (ACTION_DOWN): 0:(533.0,116.0)
:Sending Touch (ACTION_UP): 0:(527.76404,122.64124)
:Sending Trackball (ACTION_MOVE): 0:(4.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,3.0)
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
:Sending Touch (ACTION_DOWN): 0:(182.0,968.0)
:Sending Touch (ACTION_UP): 0:(180.04451,967.914)
:Sending Touch (ACTION_DOWN): 0:(59.0,1099.0)
:Sending Touch (ACTION_UP): 0:(63.1565,1100.9329)
:Sending Touch (ACTION_DOWN): 0:(160.0,648.0)
:Sending Touch (ACTION_UP): 0:(171.21176,659.42303)
:Sending Touch (ACTION_DOWN): 0:(471.0,296.0)
:Sending Touch (ACTION_UP): 0:(474.7892,296.1593)
:Sending Touch (ACTION_DOWN): 0:(525.0,732.0)
:Sending Touch (ACTION_UP): 0:(540.36957,727.0222)
:Sending Touch (ACTION_DOWN): 0:(28.0,639.0)
:Sending Touch (ACTION_UP): 0:(33.681583,645.9304)
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-5.0)
:Sending Trackball (ACTION_MOVE): 0:(3.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(0.0,3.0)
//[calendar_time:2016-12-30 10:07:37.953 system_uptime:327924986]
// Sending event #500
:Sending Touch (ACTION_DOWN): 0:(704.0,316.0)
:Sending Touch (ACTION_UP): 0:(703.73676,318.3216)
:Sending Touch (ACTION_DOWN): 0:(39.0,1155.0)
:Sending Touch (ACTION_UP): 0:(59.066753,1196.1931)
:Sending Touch (ACTION_DOWN): 0:(664.0,1011.0)
:Sending Touch (ACTION_UP): 0:(646.54816,1024.3818)
:Sending Touch (ACTION_DOWN): 0:(13.0,364.0)
:Sending Touch (ACTION_UP): 0:(15.400623,374.49005)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-5.0)
:Sending Touch (ACTION_DOWN): 0:(42.0,327.0)
:Sending Touch (ACTION_UP): 0:(41.867172,336.35474)
:Sending Touch (ACTION_DOWN): 0:(173.0,1022.0)
:Sending Touch (ACTION_UP): 0:(245.828,942.9257)
:Sending Trackball (ACTION_MOVE): 0:(4.0,0.0)
:Sending Touch (ACTION_DOWN): 0:(176.0,13.0)
:Sending Touch (ACTION_UP): 0:(179.3588,25.73448)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,1.0)
:Sending Touch (ACTION_DOWN): 0:(659.0,827.0)
//[calendar_time:2016-12-30 10:07:38.800 system_uptime:327925833]
// Sending event #600
:Sending Touch (ACTION_UP): 0:(642.80664,738.9083)
:Sending Touch (ACTION_DOWN): 0:(272.0,413.0)
:Sending Touch (ACTION_UP): 0:(263.0613,426.05515)
:Sending Trackball (ACTION_MOVE): 0:(3.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-3.0)
:Sending Trackball (ACTION_MOVE): 0:(0.0,-1.0)
:Sending Touch (ACTION_DOWN): 0:(102.0,920.0)
:Sending Touch (ACTION_UP): 0:(100.50528,927.96704)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-1.0)
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,0.0)
//[calendar_time:2016-12-30 10:07:39.343 system_uptime:327926376]
// Sending event #700
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
:Sending Touch (ACTION_DOWN): 0:(378.0,1023.0)
:Sending Touch (ACTION_UP): 0:(358.53064,1010.49554)
:Sending Touch (ACTION_DOWN): 0:(28.0,71.0)
:Sending Touch (ACTION_UP): 0:(41.35172,66.56524)
:Sending Touch (ACTION_DOWN): 0:(407.0,826.0)
:Sending Touch (ACTION_UP): 0:(408.63123,832.1906)
:Sending Touch (ACTION_DOWN): 0:(130.0,1077.0)
:Sending Touch (ACTION_UP): 0:(142.4488,1086.3716)
:Sending Trackball (ACTION_MOVE): 0:(4.0,2.0)
:Sending Touch (ACTION_DOWN): 0:(59.0,734.0)
:Sending Touch (ACTION_UP): 0:(86.33307,709.5014)
:Sending Touch (ACTION_DOWN): 0:(606.0,830.0)
:Sending Touch (ACTION_UP): 0:(589.3896,853.6812)
:Sending Touch (ACTION_DOWN): 0:(114.0,680.0)
:Sending Touch (ACTION_UP): 0:(48.745926,671.23145)
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl } in package com.xdstock.app.andriod.client
:Sending Touch (ACTION_DOWN): 0:(19.0,96.0)
:Sending Touch (ACTION_UP): 0:(16.348267,84.01233)
:Sending Touch (ACTION_DOWN): 0:(218.0,1224.0)
:Sending Touch (ACTION_UP): 0:(245.40031,1225.2307)
:Sending Touch (ACTION_DOWN): 0:(49.0,79.0)
:Sending Touch (ACTION_UP): 0:(158.67802,0.0)
:Sending Touch (ACTION_DOWN): 0:(492.0,539.0)
:Sending Touch (ACTION_UP): 0:(605.5082,540.785)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,-5.0)
:Sending Touch (ACTION_DOWN): 0:(543.0,573.0)
//[calendar_time:2016-12-30 10:07:40.276 system_uptime:327927309]
// Sending event #800
:Sending Touch (ACTION_UP): 0:(558.98114,561.69336)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,0.0)
// Allowing start of Intent { cmp=com.xdstock.app.andriod.client/.bz0120.view.impl.SC0120A00ViewImpl } in package com.xdstock.app.andriod.client
// Allowing start of Intent { cmp=com.xdstock.app.andriod.client/.bz0115.view.impl.SC0115A01ViewImpl } in package com.xdstock.app.andriod.client
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-1.0)
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
:Sending Touch (ACTION_DOWN): 0:(337.0,1090.0)
:Sending Touch (ACTION_UP): 0:(351.35196,1095.9177)
:Sending Touch (ACTION_DOWN): 0:(308.0,895.0)
:Sending Touch (ACTION_UP): 0:(329.33948,882.9762)
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.xdstock.app.andriod.client/.main.view.impl.MainViewImpl } in package com.xdstock.app.andriod.client
:Sending Touch (ACTION_DOWN): 0:(706.0,1137.0)
:Sending Touch (ACTION_UP): 0:(706.0887,1150.0319)
:Sending Touch (ACTION_DOWN): 0:(247.0,133.0)
:Sending Touch (ACTION_UP): 0:(233.58006,120.48628)
:Sending Touch (ACTION_DOWN): 0:(130.0,290.0)
:Sending Touch (ACTION_UP): 0:(122.81747,289.9176)
:Sending Touch (ACTION_DOWN): 0:(415.0,972.0)
:Sending Touch (ACTION_UP): 0:(410.91327,969.0616)
:Sending Touch (ACTION_DOWN): 0:(293.0,570.0)
:Sending Touch (ACTION_UP): 0:(311.4817,571.56934)
:Sending Touch (ACTION_DOWN): 0:(97.0,232.0)
:Sending Touch (ACTION_UP): 0:(70.9029,252.15994)
:Sending Touch (ACTION_DOWN): 0:(285.0,950.0)
:Sending Touch (ACTION_UP): 0:(338.1729,874.0263)
:Sending Touch (ACTION_DOWN): 0:(143.0,264.0)
:Sending Touch (ACTION_UP): 0:(138.88953,265.54086)
:Sending Touch (ACTION_DOWN): 0:(405.0,48.0)
:Sending Touch (ACTION_UP): 0:(403.01147,68.17992)
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-5.0)
//[calendar_time:2016-12-30 10:07:42.158 system_uptime:327929190]
// Sending event #900
:Sending Touch (ACTION_DOWN): 0:(561.0,1106.0)
:Sending Touch (ACTION_UP): 0:(557.2444,1114.111)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,1.0)
:Sending Touch (ACTION_DOWN): 0:(195.0,1041.0)
:Sending Touch (ACTION_UP): 0:(188.06357,1005.5311)
:Sending Trackball (ACTION_MOVE): 0:(1.0,2.0)
:Sending Touch (ACTION_DOWN): 0:(270.0,277.0)
:Sending Touch (ACTION_UP): 0:(172.09303,162.36142)
:Sending Touch (ACTION_DOWN): 0:(337.0,482.0)
:Sending Touch (ACTION_UP): 0:(357.15833,483.30054)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-4.0)
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
:Sending Trackball (ACTION_MOVE): 0:(0.0,3.0)
:Sending Touch (ACTION_DOWN): 0:(635.0,927.0)
:Sending Touch (ACTION_UP): 0:(639.4323,914.7981)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,3.0)
Events injected: 1000
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=8136ms (0ms mobile, 0ms wifi, 8136ms not connected)
// Monkey finished
补充
Monkey测试 参数说明: <a href='http://ihongqiqu.com/2015/12/24/Android-Monkey-Test/' target='__blank'>http://ihongqiqu.com/2015/12/24/Android-Monkey-Test/</a>
网友评论