Selecting between Given and When #GivenWhenThenWithStyle

The next topic for writing Given-When-Then With Style is choosing between describing something in the Given step or the When step.

In many cases, especially with scenarios that require complex set-up, or calculation rules where some information can be implied from the title, it’s not easy to decide where to put a key piece of data.

Here are several options describing essentially the same scenario in different ways:

Option 1: Implied When

Scenario: Gross price calculation

Given a net price of 100 EUR
And a tax rate of 9%
Then the gross price should be 109.00 EUR

Option 2: Use an input in When

Scenario: Gross price calculation

Given a net price of 100 EUR
When the tax rate is 9%
Then the gross price should be 109.00 EUR

Option 3: Skip the “Given” part

Scenario: Gross price calculation

When a net price is 100 EUR
And the tax rate is 9%
Then the gross price should be 109.00 EUR

Option 4: Explicitly state the action

Scenario: Gross price calculation

Given a net price of 100 EUR
And a tax rate of 9%
When the gross price is calculated
Then the result should be 109.00 EUR

Participate in the challenge

Which of these options looks best to you? Do you have a better solution?

To participate in this challenge, cast your vote for one of the options, or add your own proposal using the link below.

We’re switching back to weekly post cycles, so please vote by Monday 12th October. We’ll publish the results on Tuesday 13th October. The survey is now closed.

Stay up to date with all the tips and tricks and follow SpecFlow on Twitter or LinkedIn.

PS: … and don’t forget to share the challenge with your friends and team members by clicking on one of the social icons below 👇