数据驱动测试 - 使用Nunit的示例表

时间:2018-05-24 12:47:20

标签: c# selenium nunit specflow

我的任务是使用c#创建测试。我有我的specflow,当时,然后。在我的测试中,我有一个示例表。当我生成步骤定义时,我将传递此

的参数
| Lifecyclestatus |
| Prenew          |
| New             |
| Current         |
| Clearance       |
| Old             |

1 个答案:

答案 0 :(得分:2)

可以使用Scenario大纲实现数据驱动测试。所有参数都需要在示例部分中提及。请参阅以下示例功能

Scenario Outline: Addition Check with multiple set of data
    Given I have entered <Number 1> into the calculator
    And I have entered <Number 2> into the calculator
    When I press add
    Then the result should be <Result> on the screen

Examples: 
| Number 1 | Number 2 | Result |
| 10       | 20       | 30     |
| 15       | 25       | 40     |
| 50       | 90       | 140    |
| 2        | 2        | 4      |    

将对示例部分中提到的所有数据执行上述方案。