工欲善其事 必先利其器

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 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:

NewFounder的个人空间 引用 删除 NewFounder   /   2013-08-30 11:34:29
你好,我最近一直在学习MonkeyTalk,能问你一个知识点吗?我现在遇到的是这么一种情况,程序中有个可以打电话的button,然后想从打电话的界面回到程序中,应该用什么?我用Device * Back %thinktime=2000, 不起作用。
引用 删除 aaa晴空   /   2013-07-11 14:56:08
要是能把那些文档所有的英文都翻译成中文就好了
 

评分:0

我来说两句

Open Toolbar