【问题标题】:Describing a 'waiting' step on gherkin language描述小黄瓜语言的“等待”步骤
【发布时间】:2015-03-31 18:06:04
【问题描述】:

我正在尝试用小黄瓜语言描述我的应用程序场景,以便我可以将其用作可执行规范。该场景更不是以下内容:有一个执行检查的过程阶段。如果满足检查的所有条件,则过程结束。否则,该过程等待任何条件发生变化(它会收到通知)并再次检查,如果成功则结束。我无法描述的是这个等待部分。我当前的版本(简化版)是:

Given condition A 
And not condition B
When the check is performed
Then the result is negative, pending condition B

我想用pending condition B 表达的是,一旦条件 B 发生变化,就会重复测试,但我不是特别喜欢这个版本,因为很难一对一地进行测试(事实上condition B 更改将是一个新的 When)。

任何有更多经验的人能想出更好的配方吗?

【问题讨论】:

    标签: bdd gherkin


    【解决方案1】:

    您可以将两个测试链接在一起,如下所示:

    Scenario: When A and not B result is negative, but if B happens then result is positive
      Given condition A 
      But not condition B
      Then the check returns negative
      But if condition B
      Then the check returns positive
    

    这可能不是最佳实践,但有时是务实的做事方式,特别是如果由于被测系统或您的测试环境等原因导致测试运行缓慢时。

    或者您可以将其分为两个场景,并在幕后进行一些重复。

    Scenario: When A and not B the result is negative
      Given condition A 
      But not condition B
      Then the check returns negative
    
    Scenario: When A and B the result should be positive
      Given the system has condition A but not B
      And the check is returning negative
      When condition B
      Then the check returns positive
    

    在您的情况下,我会说选择哪一个取决于您的测试运行多长时间。如果他们很慢,那就去一个大场景。如果不是,或者由于某种原因无关紧要,那么请寻求第二个建议。第二个建议将提供有关失败原因的更多信息,这很好,但如果测试很慢,那么我认为即使您使用的是一个大场景,测试失败的原因仍然很明显。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多