【问题标题】:BDD Should I repeat givens and outcomes in consecutive scenariosBDD 我应该在连续场景中重复给定和结果吗
【发布时间】:2016-11-21 11:55:28
【问题描述】:

给定一个测试向 3rd-party API 发送消息的场景,我可以对功能中的每个场景重复某些给定,以及具有相关结果的给定。这使得每个场景都非常复杂。

如果我不这样做,那么基本上就有隐藏的假设。我的问题是,在实践中,这些隐藏的假设是否会导致问题,以及即使没有明确说明,利益相关者是否普遍理解这些假设。

非常欢迎任何降低风险的策略。我认为以涵盖“一般”给定和“一般”给定+结果的一个或多个场景作为引导,应该澄清一下,对于随后的场景,您可以忽略这些要求并认为它们已涵盖。我怀疑这仍然是一个假设。

具有 2 个“一般”给定和 2 个具有相关结果的“一般”给定的示例场景:

Scenario 1: An eligible order
    Given an order that has been placed yesterday
    And that has a value > 100
    And that has an order ID equal to 42
    And that has an affiliate reference equal to foo
    When the conversion for the order is sent
    Then the conversion has an ID equal to 42
    And the conversion has an affiliate ID equal to foo

【问题讨论】:

    标签: bdd specflow


    【解决方案1】:

    我的方法是在功能文件的顶部有一个详细的示例,比如:

    Scenario 1: An eligible order
        Given an order that has been placed yesterday
        And that has a value > 100
        And that has an order ID equal to 42
        And that has an affiliate reference equal to foo
        When the conversion for the order is sent
        Then the conversion has an ID equal to 42
        And the conversion has an affiliate ID equal to foo
    

    然后再往下不那么冗长:

    Scenario x: An eligible order does something
        Given an applicable order
        ...
    

    Given an applicable order 步骤只需按顺序调用 4 个原始步骤。

    这提供了更清晰的后续功能,但使测试仍然具有称为“幕后”的相同特定步骤。

    第一个场景将定义此功能文件的合格订单,后续的将使用它们。

    【讨论】:

    • 我喜欢把这些步骤总结成一个新的给定的想法。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2016-02-18
    • 1970-01-01
    • 1970-01-01
    • 2021-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多