Specflow入门-(7)Feature文件中的其他关键字

1. Scenario Template 和 Scenario Outline

注意到,我们写的4个Scenario中分别覆盖了四则运算的加减乘除,但每种计算都只列举出了一组测试数据,如何才能在同一个场景中使用多种测试数据?以Add two numbers为例:

Scenario: Add two numbers
	Given I have entered 50 into the calculator
	And I have entered 70 into the calculator
	When I press add
	Then the result should be 120 on the screen

修改为

Scenario Template: Add two numbers
	Given I have entered <numberA> into the calculator
	And I have entered <numberB> into the calculator
	When I press add
	Then the result should be <result> on the screen
Scenarios: 
	| numberA | numberB | result |
	| 50      | 70      | 120    |
	| 100     | 2       | 102    |

注意,

1. Scenario被修改为Scenario Template

2. Step的参数被替换为带尖括号的占位符

3. 实际的参数值被列在Scenarios的表格中

这样,上面的一个场景就有了两套测试数据,相应地,最终生成的test case就有两个。

<
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值