【问题标题】:Specflow. Parametrized tests规范流。参数化测试
【发布时间】:2014-09-23 13:51:56
【问题描述】:

我有这样的用户故事:

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|

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

【问题讨论】:

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


    【解决方案1】:

    你需要使用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 表中添加更多行

    正如 cmets 中所指出的,Examples 是 gerkin 中的定义术语,但 ScenariosExamples 在 SpecFlow 中可以正常工作

    【讨论】:

    • 关键字是Examples,而不是Scenarios。提出修改建议。
    • @paulroho 要么是可以接受的,至少在 SpecFlow see this 中对于映射的定义是 "examples": "Examples|Scenarios",但为了清晰起见进行了更新。谢谢!
    • @SamHolder 啊,谢谢你的提示!不知道。
    猜你喜欢
    • 1970-01-01
    • 2015-08-13
    • 1970-01-01
    • 2017-04-09
    • 1970-01-01
    • 2021-08-28
    • 1970-01-01
    • 2022-11-24
    • 2019-01-29
    相关资源
    最近更新 更多