android 自动化压力测试-monkey 1

Monkey是Android中的一个命令行工具,可以运行在模拟器里或实际设备中。它向系统发送伪随机的用户事件流(如按键输入、触摸屏输入、手势输入等),实现对正在开发的应用程序进行压力测试。Monkey测试是一种为了测试软件的稳定性、健壮性的快速有效的方法。

最近在测试公司手机软件app,抽空研究了下手机自动压力测试-monkey,如下:

步骤1:电脑环境准备:搭建android 开发环境

步骤2:手机环境准备:安装待测试的apk

步骤3:打开cmd,进入adb shell,命令如下:

C:\Users\chenshan>adb shell
[email protected]-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
时间: 2024-10-17 11:27:12

android 自动化压力测试-monkey 1的相关文章

android 自动化压力测试-monkey 3 命令参数

使用monkey help 命令查看命令参数,如下: C:\Users\chenfenping>adb shell monkey -helpusage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...][-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...][--ignore-crashes] [--ignore-timeouts][--ignore-security-exceptions][--monitor-n

android 自动化压力测试-monkey 2 获取程序包名

monkey 1 中我们写到: C:\Users\chenshan>adb shell [email protected]-T20:/ $ monkey -p cn.emoney.acg -v 500 说明:-p :指定被测试apk,主Activity(第一个启动的Activity)所在的包名(我问的开发) -v :指定测试的次数 也可以通过如下方法来获取机器中所有的包名: #adb shell #su #cd data/data #ls 如果提示:opendir failed, Permiss

Android自动化压力测试图解教程——Monkey工具

转自:http://blog.csdn.net/lfyx1357/article/details/7418133 有时候我们需要对一个软件进行压力测试,检查该软件的性能.如果是人工进行测试的话,效率会低很多,而且会比较枯燥.这时,Android中的一个命令行工具Monkey就可以为我们减轻很多重复而又繁琐的工作. 一.Monkey简介 至于Monkey的名字是有何而来的呢?这个没有去怎么考究,Monkey这个工具就是一个调皮的猴子,在App中乱按.乱摸.乱滚.乱跳.Monkey测试是Androi

Android APP压力测试-Monkey

压力测试-Monkey学习 Monkey测试特点 什么是Monkey test? 如其名,像猴子一样,虽然什么都不懂,但是可以乱点一通,可以理解为压力测试.在规定的时间或次数范围内做任何随机的操作,随即操作包括点击.滑动...... Monkey测试目标:通过模拟用户随机操作时间,暴露应用内Crash,降低Crash率 Monkey Test范围预期:除了一些系统设置,我们希望范围维持在待测试应用内,另外可以补充一些中断测试 只能发现Crash,单复现和解决Crash还是需要靠开发人员 暴露所有

Android自动化压力测试之Monkey Test (三)

Monkey 是什么? Monkey是Google提供的一个用于稳定性与压力测试的命令行工具. Monkey路径: 路径:/System/framework/monkey.jar 启动脚本路径:/system/bin/monkey 1.首先我们先打开安卓模拟器 2.打开本地cmd命令窗口 3.输入命令查看 模拟器是否有连接上 adb devices      ,出现如下图所示说明已连接上 4.然后就可以输入 adb shell 命令 进入monkey的路径下去执行monkey test了 cd

Android自动化压力测试之Monkey Test Android常见的错误类型及黑白名单的使用方法(四)

Android常见的错误类型有两种 1.ANR类型 1)在5秒内没有响应输入的事件(例如,按键按下,屏幕触摸) 2)BroadcastReceiver在10秒内没有执行完毕 2.Crash类型 1)异常停止 2)异常退出 Monkey 调试参数 --kill-process-after-error  犹豫一个错误而停止时,出错的应用程序将继续处于运行状态 --wait-dbg   启动monkey后,先中断其运行,等待调试器附加上来 命令演示 adb shell monkey -p com.da

Android手机monkey命令自动化压力测试

这里我们使用网上下载的QQ手机安装程序QQ_244.apk为例 一.安装程序 有以下两种方法: 通过DDMS安装,将程序安装包拖到模拟器data/app目录即可自动安装 装的软件都是在这个data/app, system/app是系统里的软件,data/app这个文件夹里的软件是占用手机内存 2.通过adb命令安装 复制QQ_244.apk安装文件复制到sdk\platform-tools下,也就是和adb在同一个文件夹 cd 到该文件夹下面  执行命令adb install QQ_244.ap

Android APP压力测试(二)之Monkey信息自动收集脚本

Android APP压力测试(二) 之Monkey信息自动收集脚本 前言: 上一篇Monkey介绍基本搬抄官方介绍,主要是为了自己查阅方便.本文重点介绍我在进行Monkey时如何自动收集相关信息,主要收集Monkey测试日志.手机日志.手机屏幕截图.测试手机信息,自动按次按时间点保存信息.只需轻轻一点,腾出手腾出脑想干吗干吗,执行结束应该有信息的都有收集,一定程序提升了效率,节约了时间.可以偷空看看美图.聊天扯淡...哦不,是学习提高审美观,沟通交流增进同事情感... 转载请注明出处:Find

Android APP压力测试(三)之Monkey日志自动分析脚本

Android APP压力测试(三) 之Monkey日志自动分析脚本 前言 上次说要分享Monkey日志的分析脚本,这次贴出来分享一下,废话不多说,请看正文. [目录] 1.Monkey日志分析脚本 2.脚本原理 3.操作实例 1.Monkey日志分析脚本 1).脚本文件:Monkey_Log分析.bat @ECHO OFF ECHO.::::::::::::::::::::::::::::::::::::::::::::::::: ECHO.::             分析Monkey日志