工欲善其事 必先利其器
MonkeyTalk的使用(二)
上一篇 /
下一篇 2013-01-24 21:22:39
/ 个人分类:测试工具
这两天没什么时间看这个东西,但还是大概了解了它的参数化和校验。
1. MonkeyTalk自己的脚本格式类似如下
# simple script. to login as joeInput username EnterText danmyInput 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 Tap
3. 可以在mt脚本中引用其他脚本
Script. login.mt Run
4. 支持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.csv
5. 校验点
脚本中使用verify命令支持校验
Vars * Define usr="default-at-example.com" pwd=name
Input 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.csv
7. 此外还支持命令行执行、支持转换为js执行。 因为是通过http消息通信,也支持Json接口
接口包括PING、PLAY、RECORD三类指令消息
收藏
举报
TAG: