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
,那么在所有情况下都会出现这种情况呢?
答案 0 :(得分:2)
是的,这是可行的 - 你基本上只是改变什么时候和))
Background:
Given I have bought a new car
And I add fluffy dice to the mirror