Specflow。参数化测试

时间:2014-09-23 13:51:57

标签: c# .net specflow qa automated-tests

我有这样的用户故事:

Given I am on the 'Login page'
When I enter following credentials
     |Email |Pass |
     |email1|pass1|
     |email2|pass2|
Then I get next 'Error' messages
     |ErrorMessage |
     |ErrorMessage1|
     |ErrorMessage2|

如何做到这一点? 问题是,通过我的实现,Web驱动程序从第一个表输入所有凭据,然后尝试断言错误消息,但我需要多次运行测试(循环类型)。

1 个答案:

答案 0 :(得分:4)

您需要使用scenario outline

Scenario Outline: some name...
    Given I am on the 'Login page'
    When I enter the email <email> and password <password>
    Then I get next the error message <errorMessage>
Examples:
    | email | password | errorMessage |
    | email1| pass1    | ErrorMessage1|
    | email2| pass2    | ErrorMessage2|

这将运行相同的测试两次,对Examples表中的每一行执行一次。如果您希望测试运行更多次,只需向Examples

添加更多行

正如评论中指出的那样,Examples是gerkin中定义的术语,但ScenariosExamples在SpecFlow中正常工作

相关问题