MonkeyTalk自动化之——Tests and Verification

     测试简单来说就是对脚本的调用,同时把测试结果添加到junit的XML报告中。

每条命令可以成功执行,验证了预期的组件是存在的。同时我们还可以通过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 login.mt Run joe-at-doe.com "i like cheese" "Joe Doe"

verify可以验证所有的组件,除了脚本和硬件设备,用来检查实际值和预期值是否符合,verify有3个可选参数:

expectedValue, propPath, and failMessage

1、不带参数时,只是用来验证该组件存在

例如:

Button LOGIN Verify

2、当只有参数expectedValue时,用来验证该组件的值,即该组件的逻辑值

例如:button的值是标签,input(input既是输入框)的值是text,checkbox的值是on或者off

Button LOGIN Verify LOGIN

3、当有expectedValuepropPath时,用来验证组件的属性,一些属性例如value和item是MonkeyTalk特有的属性路径,并支持跨平台,propPath组件是特定平台的,并且以逗号开头

例如:验证IOS版本上面的字体名字

Button LOGIN Verify Helvetica .font.fontName

检查android RatingBar上面star的个数

RatingBar reviewRating Verify 5 .numStars

4、failMessage参数用来提示验证失败信息

例如:

Input username Verify joe-at-doe.com value "bad username!!!"

     在测试实际值和期望值时,就需要使用verify动作,下面说明下verify的各种使用方式

  • Verify - Verify that the component's value is equal to the argument. 验证实际值等于参数
  • VerifyNot - Verify that the component's value is NOT equal to the argument. 验证实际值不等于参数
  • VerifyRegex - Verify that the component's value matches the Regular Expression provided in the argument. 验证实际值与提供的正则表达式匹配
  • VerifyNotRegex - Verify that the component's value does NOT match the Regular Expression provided in the argument.验证实际值与提供的正则表达式不匹配
  • VerifyWildcard - Verify that the component's value matches some wildcard expression provided in the argument.
  • VerifyNotWildcard - Verify that the component's value does NOT match some wildcard expression provided in the argument.
  • VerifyImage - Verify that the component's image matches the provided image file (aka image comparison) — seeImage Comparison docs.  根据图片匹配来进行验证
     同时可以设置验证时间,用来延长或者缩短验证所需要的时间。

例如:时间为毫秒

Slider Speed Verify 123 value
Label Greeting VerifyWildcard "Hello *"
Input ssn VerifyRegex \d{3}-\d{2}-\d{4} value "Invalid SSN"
# Allow a max of 4 seconds for welcome message to appear
Label Greeting VerifyWildcard "Hello *" %timeout=4000

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值