Cucumber/Gherkin - 在 "Background" 中放置 "When" 条款是否可以接受?

Cucumber/Gherkin - Is it acceptable to place "When" terms within the "Background"?

我的 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 怎么样,因为它存在于所有场景中?

是的,这是可行的 - 您基本上只需更改时间和 ))

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