1、首先测试设备是否连接成功,在命令行中输入:

  adb devices

  

  如果出现设备信息,代表链接成功。我这里的设备名称是“emulator-5554”

2、得到测试apk的包名,如果有APK源码包的话直接将“.apk”后缀改为“.zip”然后打开包中的AndroidManifest.xml可以查看包名,

   如果没有或者已经安装的点击应用程序,然后查看logcat信息,也能够找到包名,同时在/data/data/目录下面有全部的应用程序的包名,

   查询命令是:

    adb shell

     #cd /data/data

#ls

  

  

   我们要测试的包名为:com.chaozh.iReaderFree

3、设定参数

   首先用一个最简单的例子分析

   adb shell monkey -p com.chaozh.iReaderFree -v -v -v 100

   -p参数:表示指定测试的程序

   -v参数:表示查看Monkey生成的一些详细的随机的事件名 数字100:表示测试事件数为100

4、结果分析

F:\>adb shell monkey -p com.chaozh.iReaderFree -v -v -v 100
:Monkey: seed=0 count=100
:AllowPackage: com.chaozh.iReaderFree
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Selecting main activities from category android.intent.category.LAUNCHER

//(百度翻译)选择主要活动范畴android.intent.category.launcher

// 查看下方显示的信息,加黑部分,发现 (from package com.chaozh.iReaderFree)包前面是“+”号,代表这个包是活动的,就是咱们现在正在测试的

// - NOT USING main activity com.android.calendar.AllInOneActivity (from packa
ge com.android.calendar)
// - NOT USING main activity com.android.music.MusicBrowserActivity (from pack
age com.android.music)
// - NOT USING main activity com.android.deskclock.DeskClock (from package com
.android.deskclock)
// - NOT USING main activity com.android.mms.ui.ConversationList (from package
com.android.mms)
// - NOT USING main activity com.android.email.activity.Welcome (from package
com.android.email)
// - NOT USING main activity com.android.camera.GalleryPicker (from package co
m.android.gallery)
// - NOT USING main activity com.android.settings.Settings (from package com.a
ndroid.settings)
// - NOT USING main activity com.android.browser.BrowserActivity (from package
com.android.browser)
// - NOT USING main activity com.android.camera.Camera (from package com.andro
id.camera)
// - NOT USING main activity com.android.contacts.activities.DialtactsActivity
(from package com.android.contacts)
// - NOT USING main activity com.android.contacts.activities.PeopleActivity (f
rom package com.android.contacts)
// - NOT USING main activity com.example.android.apis.ApiDemos (from package c
om.example.android.apis)
// - NOT USING main activity com.android.widgetpreview.WidgetPreviewActivity (
from package com.android.widgetpreview)
// - NOT USING main activity com.android.gesture.builder.GestureBuilderActivit
y (from package com.android.gesture.builder)
// + Using main activity com.chaozh.iReader.ui.activity.WelcomeActivity (from
package com.chaozh.iReaderFree)
// - NOT USING main activity com.android.customlocale2.CustomLocaleActivity (f
rom package com.android.customlocale2)
// - NOT USING main activity com.android.providers.downloads.ui.DownloadList (
from package com.android.providers.downloads.ui)
// - NOT USING main activity com.android.quicksearchbox.SearchActivity (from p
ackage com.android.quicksearchbox)
// - NOT USING main activity com.android.calculator2.Calculator (from package
com.android.calculator2)
// - NOT USING main activity com.android.speechrecorder.SpeechRecorderActivity
(from package com.android.speechrecorder)
// - NOT USING main activity com.android.development.Development (from package
com.android.development)
// - NOT USING main activity com.example.redmi.MainActivity (from package com.
example.redmi)
// - NOT USING main activity com.example.android_image.MainActivity (from pack
age com.example.android_image)
// - NOT USING main activity com.example.android_mp3.MainActivity (from packag
e com.example.android_mp3)
// - NOT USING main activity com.wiseweb.activity.Splash (from package com.wis
eweb.movie)
// Selecting main activities from category android.intent.category.MONKEY
// - NOT USING main activity com.android.launcher2.Launcher (from package com.
android.launcher)
// - NOT USING main activity com.android.settings.Settings$RunningServicesActi
vity (from package com.android.settings)
// - NOT USING main activity com.android.settings.Settings$StorageUseActivity
(from package com.android.settings)
// Seeded: 0
// Event percentages:

//(百度翻译)事件百分比

// 分别代表的意思如下 0~9 ,都是百度翻译的,不知道正确与否

// 0::[--pct-touch PERCENT]     → 触摸百分比

// 1和2:[--pct-motion PERCENT]   → 运动百分比

// 3:[--pct-trackball PERCENT]         → 追踪球百分比

// 4:[--pct-syskeys PERCENT]     → syskeys百分比

// 5:[--pct-nav PERCENT]                → 网络百分比

// 6:[--pct-majornav PERCENT]        → 主要网络百分比

// 7:[--pct-appswitch PERCENT]       → app转换百分比

// 8:[--pct-flip PERCENT]                 → 翻转百分比

// 9:[--pct-anyevent PERCENT]         → 任何情况百分比

// 0: 15.0%  
// 1: 10.0%
// 2: 2.0%
// 3: 15.0%
// 4: 25.0%
// 5: 15.0%
// 6: 2.0%
// 7: 2.0%
// 8: 1.0%
// 9: 13.0%

//表示跳转到com.chaozh.iReaderFree里面的Gallery这一个Activity

:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10000000;component=com.chaozh.iReaderFree/com.chaozh.
iReader.ui.activity.WelcomeActivity;end

//表示com.chaozh.iReaderFree包上允许启动程序(act=...)

// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.chaozh.iReaderFree/com.chaozh.iReader.ui.activit
y.WelcomeActivity } in package com.chaozh.iReaderFree

//表示睡眠的时间0毫秒,直接开始,然后开始发送一系列指令,如点击、放开、移动

//可以用--throttle来设置一个起效的事件发生后时延时

Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 22 // KEYCODE_DPAD_RIGHT
:Sending Key (ACTION_UP): 22 // KEYCODE_DPAD_RIGHT
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 23 // KEYCODE_DPAD_CENTER
:Sending Key (ACTION_UP): 23 // KEYCODE_DPAD_CENTER
Sleeping for 0 milliseconds
:Sending Flip keyboardOpen=false
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 20 // KEYCODE_DPAD_DOWN
:Sending Key (ACTION_UP): 20 // KEYCODE_DPAD_DOWN
Sleeping for 0 milliseconds
:Sending Touch (ACTION_DOWN): 0:(153.0,207.0)
:Sending Touch (ACTION_UP): 0:(153.19875,207.49512)
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 82 // KEYCODE_MENU
:Sending Key (ACTION_UP): 82 // KEYCODE_MENU
Sleeping for 0 milliseconds
:Sending Touch (ACTION_DOWN): 0:(267.0,244.0)
:Sending Touch (ACTION_UP): 0:(272.7109,242.90211)
Sleeping for 0 milliseconds
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,0.0)
:Sending Trackball (ACTION_MOVE): 0:(3.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(0.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(3.0,-5.0)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,0.0)
:Sending Trackball (ACTION_MOVE): 0:(1.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-3.0)
:Sending Trackball (ACTION_MOVE): 0:(3.0,-3.0)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,1.0)
:Sending Key (ACTION_DOWN): 20 // KEYCODE_DPAD_DOWN
:Sending Key (ACTION_UP): 20 // KEYCODE_DPAD_DOWN
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 21 // KEYCODE_DPAD_LEFT

//拒绝此跳转,因为它是跳转的到非它自己的包的Activity,本测试中是指测试它程序所在的包,此跳转是跳出本程序,进入桌面。

// Allowing start of Intent { cmp=com.chaozh.iReaderFree/com.zhangyue.iReade
r.read.ui.Activity_BookBrowser_TXT } in package com.chaozh.iReaderFree

//继续发送指令

:Sending Key (ACTION_UP): 21 // KEYCODE_DPAD_LEFT
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 46 // KEYCODE_R
:Sending Key (ACTION_UP): 46 // KEYCODE_R
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 23 // KEYCODE_DPAD_CENTER
:Sending Key (ACTION_UP): 23 // KEYCODE_DPAD_CENTER
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 21 // KEYCODE_DPAD_LEFT
:Sending Key (ACTION_UP): 21 // KEYCODE_DPAD_LEFT
Sleeping for 0 milliseconds
:Sending Trackball (ACTION_MOVE): 0:(1.0,-3.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-5.0)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(-1.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-5.0)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,-4.0)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(1.0,3.0)
:Sending Key (ACTION_DOWN): 82 // KEYCODE_MENU
:Sending Key (ACTION_UP): 82 // KEYCODE_MENU
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 178 // KEYCODE_TV_INPUT
:Sending Key (ACTION_UP): 178 // KEYCODE_TV_INPUT
Sleeping for 0 milliseconds
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-2.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(0.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(0.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,0.0)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,0.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,1.0)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,4.0)
:Sending Trackball (ACTION_DOWN): 0:(0.0,0.0)
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 3 // KEYCODE_HOME
:Sending Key (ACTION_UP): 3 // KEYCODE_HOME

//表示com.chaozh.iReaderFree包上允许启动程序(cmp=...),然后开始发送一系列指令,如点击、放开、移动

// Rejecting start of Intent { act=android.intent.action.MAIN cat=[android.i
ntent.category.HOME] cmp=com.android.launcher/com.android.launcher2.Launcher } i
n package com.android.launcher
Sleeping for 0 milliseconds
:Sending Touch (ACTION_DOWN): 0:(257.0,143.0)
:Sending Touch (ACTION_UP): 0:(248.47726,134.0601)
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 126 // KEYCODE_MEDIA_PLAY
:Sending Key (ACTION_UP): 126 // KEYCODE_MEDIA_PLAY
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 20 // KEYCODE_DPAD_DOWN
:Sending Key (ACTION_UP): 20 // KEYCODE_DPAD_DOWN
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 21 // KEYCODE_DPAD_LEFT
:Sending Key (ACTION_UP): 21 // KEYCODE_DPAD_LEFT
Sleeping for 0 milliseconds
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-2.0)
:Sending Trackball (ACTION_MOVE): 0:(1.0,1.0)
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-2.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(3.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-4.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-2.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-2.0)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,3.0)
:Sending Touch (ACTION_DOWN): 0:(33.0,453.0)
:Sending Touch (ACTION_POINTER_DOWN 1): 0:(37.53572,452.94702) 1:(283.0,88.0)
:Sending Touch (ACTION_MOVE): 0:(38.494465,452.9393) 1:(289.34943,87.55577)
:Sending Touch (ACTION_POINTER_UP 1): 0:(44.913345,452.7924) 1:(295.43988,87.318
954)
:Sending Touch (ACTION_UP): 0:(47.022545,452.70322)
Sleeping for 0 milliseconds
:Sending Touch (ACTION_DOWN): 0:(300.0,208.0)
:Sending Touch (ACTION_MOVE): 0:(301.1697,213.4518)
:Sending Touch (ACTION_MOVE): 0:(304.233,218.98541)
:Sending Touch (ACTION_MOVE): 0:(305.48483,225.51746)
:Sending Touch (ACTION_MOVE): 0:(307.53262,234.67958)
:Sending Touch (ACTION_MOVE): 0:(310.49463,238.96536)
:Sending Touch (ACTION_MOVE): 0:(312.6929,247.50093)
:Sending Touch (ACTION_MOVE): 0:(314.07666,254.9053)
:Sending Touch (ACTION_MOVE): 0:(315.71674,256.64383)
:Sending Touch (ACTION_UP): 0:(318.2656,263.68002)
Sleeping for 0 milliseconds
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-4.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,1.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,2.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-5.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-1.0)

//事件完成数100,丢弃的键 2 ,指针 3, 轨迹球 0 , 翻转 0

Events injected: 100
:Dropped: keys=2 pointers=3 trackballs=0 flips=0

//网络统计:共用 12388ms,其中12388ms用在手机上,0ms用来无线网上,没有连接的时间为0ms

## Network stats: elapsed time=12388ms (12388ms mobile, 0ms wifi, 0ms not connec
ted)
// Monkey finished

Monkey学习(4)简单测试实例的更多相关文章

  1. Rabbit简单测试实例

    Rabbit简单测试实例 安装环境: Yum -y install python-pip Pip install pika 生产者 1 2 3 4 5 6 7 8 9 10 11 import pik ...

  2. spring再学习之简单测试

    一.spring是怎么工作的那,通过一个类装载进容器进行描述: 首先创建一个类user: package cn.itcast.bean; public class User { public User ...

  3. C++动态链接库测试实例

    前话 上一章节我导出了一个动态链接库 要使用该链接库,我们还需要该链接库对外公开的函数,即头文件 下面开始实例 测试实例 第一步--将动态链接库的dll.lib.和头文件导入项目中 文件目录如下: 项 ...

  4. Android studio测试软件——Monkey学习及运用

    Android studio测试软件——Monkey学习及运用 在第十五周的个人博客上,王老师安排我们根据最终的团队大作业所用的软件(Android studio)进行软件测试的介绍,而我选择的是基于 ...

  5. Monkey学习(2)简单命令合集

    Monkey命令的简单帮助 执行所有命令的前提是,必须先链接模拟器或者实体机,否则会报如下错误信息: 打开命令行窗口,WIN+R,输入CMD 在命令行窗口执行:adb shell monkey –he ...

  6. Javascript学习-简单测试环境

    Javascript学习-简单测试环境 在<JavaScript忍者秘籍>2.4测试条件基础知识中,作者给出了一个精简版的assert和assert组的实现,对于初学者而言,这无疑是一个很 ...

  7. JMeter学习篇(一):测试实例讲解

    1.JMeter的下载与安装 Jmeter官方下载地址:http://jmeter.apache.org/download_jmeter.cgi,下载jmeter是一个zip压缩包,解压后,直接运行a ...

  8. IIC驱动学习笔记,简单的TSC2007的IIC驱动编写,测试

    IIC驱动学习笔记,简单的TSC2007的IIC驱动编写,测试 目的不是为了编写TSC2007驱动,是为了学习IIC驱动的编写,读一下TSC2007的ADC数据进行练习,, Linux主机驱动和外设驱 ...

  9. 【C语言C++编程学习笔记】基础语法,第一个简单的实例编程入门教程!

    C语言/C++编程学习:一个简单的实例 让我们来看一个简单的C语言程序.从下面的程序可以看出编写C语言程序的一些基本特征.   如果你能知道该程序将会在显示器上显示一些内容,那说明你还是知道一些的! ...

随机推荐

  1. python: html 笔记2

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. Http Basic认证

    Http Basic认证就是访问的时候把用户名和密码用base64加密放在request的header的authorization中 服务端直接获取authorization,解析,跟用户名匹配即可. ...

  3. jQuery.validator 详解

    jQuery.validator 详解二 前言:上一篇详细的介绍了jQuery.validator( 版本v1.13.0 )的验证规则,这一篇重点讲述它的源码结构,及如何来对元素进行验证,错误消息提示 ...

  4. Cookie案例

    实现的功能是:在页面上点击,各种书名,跳转到另一个页面,在点解return 回到原来的页面,并且最下面出现刚才点击的书名:进行多次操作,都会出现刚刚点击的书名: 类似于:在浏览器上显示你登录的记录: ...

  5. Round Numbers(组合数学)

    Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10484 Accepted: 3831 Descri ...

  6. THE DRUNK JAILER 分类: POJ 2015-06-10 14:50 13人阅读 评论(0) 收藏

    THE DRUNK JAILER Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24918   Accepted: 1563 ...

  7. hiho 第117周 二分图多重匹配,网络流解决

    描述 学校的秋季运动会即将开始,为了决定参赛人员,各个班又开始忙碌起来. 小Hi和小Ho作为班上的班干部,统计分配比赛选手的重任也自然交到了他们手上. 已知小Hi和小Ho所在的班级一共有N名学生(包含 ...

  8. 利用Spire for .NET实现办公自动化——Spire.Doc

    今天研究了一下E-ICEBLUE公司的Spire for .NET系列产品.我们可以通过利用这个系列的dll库文件轻松的实现办公自动化的需求,而且不需要安装相应的办公软件.有关于Spire .NET系 ...

  9. Redis基础

    Redis是开源的,支持网络.可基于内存也可持久化的key-value数据库,支持主从复制,读写分离,支持5种基本数据类型,高并发性能 安装redis数据库 下载:http://redis.io/do ...

  10. 再议extern和include的作用

    先引入一下题啊,主要是看到有人这样写 我个人觉的这样写没什么意思,没有体现出了extern的特性.   为什么我要这样说,先谈谈include,总是有人觉得这个东西很神秘,很特殊不知道他干了什么.其实 ...