How to balance coverage, precision and clarity? #GivenWhenThenWithStyle

Choosing a descriptive set of examples is one of the biggest challenges for good specifications. There are many ways to demonstrate any particular scenario, and finding the right balance between precision, coverage and clarity is sometimes difficult. For the next Given-When-Then With Style challenge, we’ll look into guidelines on choosing the right set of examples.

To make this more concrete, consider a volume discount rule that provides 10% off for purchases between 5 and 10 items, 15% for purchases between 10 and 20; and 20% above that. We can show this with the following scenario outline structure:

Given the purchase order contains <items>
When the user checks out
Then the discount offered should be <discount>

Here are several ways how we could capture the examples:

Option 1: Show ranges

|items            | discount |
|less than 5      |  0%      |
|between 5 and 10 | 10%      |
|between 10 and 20| 15%      |
|more than 20     | 20%      |

Option 2: Use single example from each group

|items            | discount |
|3                | 10%      |
|15               | 15%      |
|100              | 20%      |

Option 3: Show only interval edges

|items            | discount |
|1                |  0%      |
|5                |  0%      |
|6                | 10%      |
|9                | 10%      |
|10               | 15%      |
|19               | 15%      |
|20               | 20%      |
|21               | 20%      |

Option 4: Show all the values

|items            | discount |
|1                |  0%      |
|2                |  0%      |
|3                |  0%      |
...
|20               | 20%      |
|21               | 20%      |

Participate in the challenge

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

Cast your vote using the link below (or add your own solution if you do not like any of the above).

We’ll publish the results in two weeks, with an analysis of the votes and general guidelines for handling such situations. You have time until Monday 2nd of November to participate.

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 👇