我的黄瓜/小黄瓜测试包括一些基本的创建和删除,但是第一个场景包括一个过程,这是后续场景的先决条件。
例如:
如果我们有一辆新车,它的内容在某种数组中找到(因为它是新的,所以最初是空的)
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
因为这在所有场景中都存在?