黄瓜/小黄瓜 - 在“背景”中放置“何时”术语是否可以接受?

时间:2018-05-04 13:56:58

标签: java cucumber gherkin

My Cucumber / Gherkin测试涵盖了一些基本的创建和删除,但第一个场景涵盖了后续场景的先决条件。

例如:如果我们有一辆新车,其内容在某种数组中找到(最初是空的,因为它是新的)

Scenario: Adding an item to the car
    Given I have bought a new car
    When I add fluffy dice to the mirror
    Then There should be fluffy dice found in the car

Scenario: Removing an item from the car
    Given I have bought a new car
    When I add fluffy dice to the mirror
        And I remove fluffy dice from the mirror
    Then There should be no items found in the car

Scenario: Add multiple items to the car
    Given I have bought a new car
    When I add fluffy dice to the mirror
        And I a bobble head to the dashboard
    Then there should be 2 items in the car

我知道我可以将行Given I have bought a new car抽象为Background:,但是如果添加When I add fluffy dice to the mirror,那么在所有情况下都会出现这种情况呢?

1 个答案:

答案 0 :(得分:2)

是的,这是可行的 - 你基本上只是改变什么时候和))

Background: 
    Given I have bought a new car
    And I add fluffy dice to the mirror
相关问题