Executable specifications are used in BDD/Spec By Example as a mean to describe an application behaviour in business language. They are executable because they are linked to tests that exercise the behaviour of the application itself.
Let’s imagine we want to develop the solution to the FizzBuzz problem, Which one of the following solutions would you adopt and why? If you have a different better solution than the two I list, please add it!
1. Specific examples:
Given we are printing numbers using FizzBuzz
When the number is <number>
Then we will print <answer>
|number|answer|
| 1 | 1 |
| 3 | Fizz |
| 5 | Buzz |
| 6 | Fizz |
| 10 | Buzz |
| 15 |FizzBuzz|
2. Generic Rules
Given we are printing numbers using FizzBuzz
When the number is a multiple of 3
Then we will print Fizz
Given we are printing numbers using FizzBuzz
When the number is a multiple of 5
Then we will print Buzz
Given we are printing numbers using FizzBuzz
When the number is a multiple of 3 and 5
Then we will print FizzBuzz
Given we are printing numbers using FizzBuzz
When the number is a not a multiple of either 3 or 5
Then we will print the number

