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就有两个。
<