-
MonkeyTalk的使用(二)
2013-01-24 21:22:39
这两天没什么时间看这个东西,但还是大概了解了它的参数化和校验。1. MonkeyTalk自己的脚本格式类似如下# simple script. to login as joe
Input username EnterText danmy
Input password EnterText “i like cheese”
Button LOGIN Tap也支持转成js脚本执行 如load("libs/testapidemo.js");testapidemo.test1.prototype.run = function() {this.app.device().menu();this.app.menu().select("Add note");this.app.textArea("note").enterText("My test");this.app.device().back();this.app.table().selectIndex("1");this.app.menu().select("Delete");};2. 设置变量以${var} 表示变量如Vars * Define usr="default-at-example.com" pwd
Input username EnterText ${usr}
Input password EnterText ${pwd}
Button LOGIN Tap3. 可以在mt脚本中引用其他脚本Script. login.mt Run4. 支持csv格式的数据文件作数据驱动usr, pwd
joe-at-doe.com, "i like cheese"
alpha-at-beta.net, password1
charlie-at-dog.org, abc123脚本格式 Script. login.mt RunWith credentials.csv5. 校验点脚本中使用verify命令支持校验Vars * Define usr="default-at-example.com" pwd=nameInput username EnterText ${usr}
Input password EnterText ${pwd}
Button LOGIN Tap
Label welcome Verify "Welcome, ${name}!"
Button LOGOUT Verify使用Test命令执行该脚本进行校验
Test login.mt Run joe-at-doe.com "i like cheese" "Joe Doe"
6. 测试集的组织,定义为mts,包括多个mt脚本的执行语句,包含setup、teardown等部分
# setup runs before every test
Setup login.mt Run joe@doe.com “i like cheese”
# teardown runs after every test
TearDown logout.mt Run
# the tests...
Test add_contact.mt RunWith contacts.csv
Test remove_contact.mt RunWith contacts.csv7. 此外还支持命令行执行、支持转换为js执行。 因为是通过http消息通信,也支持Json接口
接口包括PING、PLAY、RECORD三类指令消息
-
用MonkeyTalk测试Android应用(一)
2013-01-22 22:03:27
MonkeyTalk是Gorilla Logic的一款开源的支持录制回放并跨平台的自动化工具。IOS下没试,Android应用测试缺点是需要应用源码,但是操作还比较方便,在此记录下使用过程1. 到http://www.gorillalogic.com/developer-resources/downloads下载对应版本的MonkeyTalk,目前最新版本是V1.0.30。 下载下来解压即可其中主要Agent和IDE,agent是一个jar包,需要编译到应用工程中。通过该Agent和IDE进行通信,实现PC上测试模拟器或手机上的应用2. 下载Eclipse的AJDT插件,用于转换应用工程http://www.eclipse.org/ajdt/downloads/3. 打开应用,如AndroidSDK下自带的Notepad应用工程。将应用转换为AspectJ工程3. 在工程下创建libs目录,并将MonkeyTalk\agent\android\目录下的agentXXX.jar拷贝到libs下4. 将agentXXX.jar加入AspectJ路径5. 修改应用的AndroidManifest.xml文件,增加权限- android.permission.INTERNET
- android.permission.GET_TASKS
6.在应用的build path中order and export tab下选中AspectJ运行库7. eclipse里执行该应用或编译好应用并部署到模拟器或设备上,打开应用此时LogCat中会打印MonkeyTalk相关的初始化信息如:MonkeyTalk(336): starting PlaybackServer on port 16862。。。MonkeyTalk(336): Initializing Device automatorMonkeyTalk(336): Initializing MenuAutomatorMonkeyTalk(336): Initializing DialogAutomatorMonkeyTalk(336): Initializing TabAutomatorMonkeyTalk(336): Initializing Input automator应用的Monkeytalk agent已正常启动8 打开MonekeyTalk IDE,通过new菜单建立一个新的MT工程9. 在刚才的MT工程下新建一个测试脚本如test1.mt,此时可以看到录制工具栏10.选择android小绿人,连接模拟器或设备,日志栏打印如下信息22:44:28.000: Connection set to Android Emulator or Tethered Device表示IDE和Agent建立了连接11. 此时在模拟器上界面上操作,即会自动生成MT的关键字视图下的脚本下面是notepad示例应用的简单录制脚本Device * menuMenu * select "Add note"TextArea note enterText "My test"Device * backTable * selectIndex 1Menu * select Delete12 停止录制后,保存脚本,可以回放操作明天再试试校验、参数化等功能 -
性能评估工具PageSpeed及Yslow
2012-02-09 21:17:35
题外话: 很久没有更新这边的blog了,想来1年多也有不少收获,还是总结总结罢。想哪是哪,先从具体的工具说起吧页面性能评估工具Yslow和PageSpeed
PageSpeed及Yslow是目前比较常用的Web页面性能评级工具先说YslowYslow是Yahoo发布的一款免费性能评估工具,提供包括Firefox,Chrome,opera,safari浏览器上的插件。基于Yahoo定义的提高webSite性能的规则集对访问的页面进行评估,给出评估结论。(http://developer.yahoo.com/performance/rules.html)详细的使用方法此处不再介绍,也比较简单,随便搜索一下也能找到。本文重点说明下命令行调用Yslow进行测试的方法,这样就可以比较顺利的实现自动化测试并加入敏捷的持续集成流程中了1. 首先Yslow是基于Node.js的(Node.js此处不多作介绍,以后再另文详述。)首先需要安装node.js,目前最新版本是0.6.10,已集成npm(node pakage manager)以笔者的windows环境为例,执行C:\Program Files\nodejs>npm install yslow -g可以发现安装不成功,原因是Yslow的一个依赖包contextify在windows环境下编译不通过,需要找替代版本。)如果是公司内网环境,有代理屏蔽之类的问题,也可直接下载好各依赖包手动安装到http://search.npmjs.org/ 查询Yslow各依赖包并下载tgz文件通过执行 npm install ***.tgz 安装安装完成后,在windows环境上可以在node中执行相关模块代码执行Yslow测试$ node > require('fs').readFile('example.com.har', function (err, data) { var har = JSON.parse(data), YSLOW = require('yslow').YSLOW, doc = require('jsdom').jsdom(), res = YSLOW.harImporter.run(doc, har, 'ydefault'), content = YSLOW.util.getResults(res.context, 'basic'); console.log(content); }); { w: 98725, o: 89, u: 'http%3A%2F%2Fexample.com%2F', r: 9, i: 'ydefault', lt: 981 }
对了,需要将待测的web页面先导出为har格式的文件(Http archive),可以通过firebox的netexport插件或者HttpWatch导出替换掉示例脚本中的har文件即可执行basic评估测试了测试类型可以是basic
,grade
,stat s
,comps
,all
规则集一般用ydefault
其他定义如下:
ynumreq score for Make fewer HTTP Requests ycdn score for Use a Content Delivery Network(CDN) yemptysrc score for Avoid empty src or href yexpires score for Add Expires headers ycompress score for Compress components with gzip ycsstop score for Put CSS at top yjsbottom score for Put JavaScript. at bottom yexpressions score for Avoid CSS expressions yexternal score for Make JavaScript. and CSS external ydns score for Reduce DNS lookups yminify score for Minify JavaScript. and CSS yredirects score for Avoid URL redirects ydupes score for Remove duplicate JavasScript. and CSS yetags score for Configure entity tags (ETags) yxhr score for Make AJAX cacheable yxhrmethod score for Use GET for AJAX requests ymindom score for Reduce the number of DOM elements yno404 score for Avoid HTTP 404 (Not Found) error ymincookie score for Reduce cookie size ycookiefree score for Use cookie-free domains ynofilter score for Avoid AlphaImageLoader filter yimgnoscale score for Do not scale images in HTML yfavicon score for Make favicon small and cacheable 另一个工具PageSpeedPageSpeed和Yslow类似,但基于不同的规则集,包括移动网络的规则。同样也是打分机制PageSpeed的命令行比较简单,下载har_to_PageSpeed 工具,命令行执行即可输出结果 http://page-speed.googlecode.com/files/har_to_pagespeed.exepagespeed还提供在线检测功能,对你提供的URL地址进行评估并给出得分
标题搜索
我的存档
数据统计
- 访问量: 22536
- 日志数: 24
- 建立时间: 2007-01-16
- 更新时间: 2016-05-21