Reputation: 6328
My Cucumber/Gherkin test covers some basic creation and deletion, however the first scenario covers a process that is a prerequisite to the subsequent scenarios.
For example: If we have a new car with contents found within an array of some sort (initially empty since it is new)
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
I know that I can abstract the line Given I have bought a new car
into a Background:
, but what about adding the When I add fluffy dice to the mirror
since this is present throughout all scenarios?
Upvotes: 0
Views: 139
Reputation: 104
Yes, this is doable - you basically just change when to and ))
Background:
Given I have bought a new car
And I add fluffy dice to the mirror
Upvotes: 3