【问题标题】:What do you recommend to perform multiple validations using Cucumber?您建议使用 Cucumber 执行多重验证?
【发布时间】:2021-06-21 23:21:01
【问题描述】:

如果我需要验证多个点,我必须在单独的场景中编写验证,还是必须将它们分组到一个场景中?我知道两者都是可能的。但是,作为 QA 工程师有什么建议呢?

例如:

Scenario: scenario A
Given I need to search for the product "xxxxx"
When I found the product on the list
And I click on the product item
And I click on the Update Icon
And I enter "xxxxx" as a new product name
And I click on the Save button
Then The system displays a successful message.
And The system redirects to the main page.

VS

Scenario: scenario A
Given I need to search for the product "xxxxx"
When I found the product on the list
And I click on the product item
And I click on the Update Icon
And I enter "xxxxx" as a new product name
And I click on the Save button
Then The system displays a successful message.

Scenario: scenario B
Given I need to search for the product "xxxxx"
When I found the product on the list
And I click on the product item
And I click on the Update Icon
And I enter "xxxxx" as a new product name
And I click on the Save button
Then The system redirects to the main page.

【问题讨论】:

    标签: cucumber bdd qa


    【解决方案1】:

    这个问题没有一般的答案,但是让我们专注于这个特定的用例。测试似乎执行了一项操作,然后断言显示成功消息并将用户重定向到主页。

    通常,每个场景只需要一个断言,因为每个测试应该只验证一个行为。由于这两种情况之间的唯一区别是Then 步骤,因此我倾向于使用两种断言的一种情况。单一场景有两个失败的原因,但调试测试失败是相当明显的。

    具有多个断言的测试更频繁地失败。经常失败的测试可以被视为不可信。如果我认为这两个断言验证的行为会经常失败,我会编写单独的场景。由于成功消息和重定向是非常简单的事情,我不希望这两种行为经常失败。因此,我相信将这两个断言归为一个场景是可以的。

    【讨论】:

    • 我完全同意你的看法。我只是在考虑如何处理这样的情况,你理解我的观点,因为每个特定的业务场景都没有规则。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-10-21
    • 2020-03-01
    • 2011-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-01
    相关资源
    最近更新 更多