Monkey学习(4)简单测试实例

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
// - 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: 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%
: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
// 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
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
// 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
// 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)
Events injected: 100
:Dropped: keys=2 pointers=3 trackballs=0 flips=0
## Network stats: elapsed time=12388ms (12388ms mobile, 0ms wifi, 0ms not connec
ted)
// Monkey finished

时间: 2024-11-02 23:01:28

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

selenium学习:数据驱动测试实例之参数化51cto登录

封装模块文件public_1.py #coding=utf-8 from selenium import webdriver from time import sleep class Login():              #登陆     def user_login(self,driver,username,password):         driver.find_element_by_id("loginform-username").clear()         driv

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

1.Monkey命令的简单帮助 执行所有命令的前提是,必须先链接模拟器或者实体机,否则会报如下错误信息: 打开命令行窗口,WIN+R,输入CMD 在命令行窗口执行:adb shell monkey –help 1) 参数:  -p 参数-p用于约束限制,用此参数指定一个或多个包(Package,即App).指定 包之后,Monkey将只允许系统启动指定的APP.如果不指定包,Monkey将允许系统启动设备中的所有APP. * 指定一个包: adb shell monkey -p com.exam

Java学习-排序二叉树性能简单测试

1.创建4万个随机数,然后用分别用冒泡法,选择法,二叉树法3种排序算法进行排序,比较哪种更快 1 package Collection; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 public class sortSpeedTest { 7 8 public static void main(String[] args) { 9 int num = 40000; // 元素个数 10 int rnd1[] = new

JMeter学习-010-JMeter 配置元件实例之 - CSV Data Set Config 参数化配置

众所周知,在进行接口测试的过程中,需要创建不同的场景(不同条件的输入,来验证不同的入参的返回结果).因而,在日常的自动化接口监控或商品监控等线上监控过程中,需要配置大量的入参来监控接口的返回是否正确. 日常常见的线上监控几个简单的监控示例场景如下: 监控电商网站某个类目下的商品数量.若类目中商品的数量小于一定的数量,则认为需要认为查看商品池的商品是否正确: 监控商品的价格.当商品价格出现超出限定的波动幅度时,通知相应的商品负责人,对其进行确认,从而保证商品价格的正确无误. 监控商品在某一地域是否

Selenium2学习-018-WebUI自动化实战实例-016-自动化脚本编写过程中的登录验证码问题

日常的 Web 网站开发的过程中,为提升登录安全或防止用户通过脚本进行黄牛操作(宇宙最贵铁皮天朝魔都的机动车牌照竞拍中),很多网站在登录的时候,添加了验证码验证,而且验证码的实现越来越复杂,对其进行脚本识别的难度也越来越高.这对我们自动化脚本编写带了非常的不便,那么如何解决登录时的验证码问题呢?经常有初学自动化脚本编写的小主们问及此问题. 此文主要针对如何解决自动化测试脚本中含登录态的操作问题,即如何降低验证码对自动化脚本编写过程中的解决方法进行分析和解决,并以实例演示(基于易迅网易迅账号登录)

struts2+hibernate+spring配置版框架搭建以及简单测试(方便脑补)

为了之后学习的日子里加深对框架的理解和使用,这里将搭建步奏简单写一下,目的主要是方便以后自己回来脑补: 1:File--->New--->Other--->Maven--->Maven Project--->Next(之后界面如下所示:) --->Next(点击next之后出现如下界面:选择最后一个 maven-archetype-webapp,然后点击next) --->Next(点击next之后出现如下界面,然后选择好组织号,工程号,版本号即可),最后点击Fi

spring aop简单日志实例

转载自:http://www.blogjava.net/laoding/articles/242611.html 一直就用spring的IOC,遗憾spring的另一重要组成部分AOP却没用过,所以近几天抽空研究了下AOP,学了些东西,在这里记录下spring2.0的aop配置,以一个简单的记录日志的实例来说明,先介绍下用XMLSchema来配置,下一篇介绍annotation配置,废话不多说,开始吧先新建个web工程,将spring的包加进去,为方便就把全部的jar包加进去. 先来看个接口,很

Monkey学习

Monkey是一个工程,生成伟随机事件流(在一段时间内完全不重复的事件流),由种子生成.可以模拟用户,点击,触屏等.最好用来做压力测试.无法做功能测试. adb shell monkey -p -v -s -throttle 延时 --pct-touch 某个事件百分比 --pct-trackball 轨迹球可以解决解锁是圆环的(这个轨迹球用monkeyrunner更合适) --pct-syskeys 有80+系统事件,这个参数会给一个值,如果不想进行交互,这项变成0即可. 分析Monkey源码

PHP机器学习库php-ml的简单测试和使用

php-ml是一个使用PHP编写的机器学习库.虽然我们知道,python或者是C++提供了更多机器学习的库,但实际上,他们大多都略显复杂,配置起来让很多新手感到绝望.php-ml这个机器学习库虽然没有特别高大上的算法,但其具有最基本的机器学习.分类等算法,我们的小公司做一些简单的数据分析.预测等等都是够用的.我们的项目中,追求的应该是性价比,而不是过分的效率和精度.一些算法和库看上去非常厉害,但如果我们考虑快速上线,而我们的技术人员没有机器学习方面的经验,那么复杂的代码和配置反而会拖累我们的项目