The BDD Cycle
Start with a failing testβ
Can you work out how to run SpecFlow so that it executes the scenarios in the feature file? Run the tests. You should see a mixture of passing and failing SpecFlow scenarios and programmer tests.
Questionsβ
1. What is the name of the passing scenario?β
Show answer
- C#
- JavaScript
- Go
InRangeShoutIsHeard
In range shout is heard
TestFeatures/In_range_shout_is_heard
2. What is the name of the failing scenario?β
Show answer
- C#
- JavaScript
- Go
OutOfRangeShoutIsNotHeard
Out of range shout is not heard
TestFeatures/Out_of_range_shout_is_not_heard
3. What is the name of the passing programmer test?β
Show answer
- C#
- Go
- JavaScript
ItCalculatesTheDistanceFromItself
TestCoordinateDistanceFrom/distance_from_itself
should calculate the distance from itself
4. What is the name of the failing programmer test?β
Show answer
- C#
- JavaScript
- Go
ItCalculatesTheDistanceFromAnotherCoordinateAlongXAxis
should calculate the distance from another coordinate along X axis
TestCoordinateDistanceFrom/distance_from_another_coordinate_along_X_axis
5. How would you explain to your product owner what is wrong with Shouty, from what you see in the test results?β
Show answer
Discuss amongst your group.
Red, Green, Refactorβ
Now we have a failing programmer test and a failing scenario. We need to get them both passing.
1. Modify the application codeβ
Write the production code that will make the failing programmer test pass. You should not need to edit the feature file, the step definition file or the programmer test file.
Thereβs a commented-out line in the Coordinate implementation that will get the programmer test passing.
2. Run the tests againβ
Run all the tests again. Both the programmer tests should be passing, but one of the scenarios should still be failing.
Does the code you have just uncommented look like a complete solution?
3. Add a unit test before making the scenario passβ
Open the programmer test file and uncomment the programmer test that is commented out.
Run all the tests again.
- Which programmer test(s) are failing?
- Which scenario(s) are failing?
- Can you see what changes you have to make to get the new programmer test to pass?
4. Modify the application code to make both tests passβ
Use Pythagoras' theorem.
Keep working and running all the tests until you see all the programmer tests, steps and scenarios pass.
Where are we in the BDD cycle?β
Now that we've got everything passing we've moved into new territory in the BDD Cycle.
Use the diagram and labels below to answer the questions that follow.

- Decide the next user story to work on
- Use concrete examples to explore and discover the acceptance criteria for the user story
- Formulate a concrete example as a scenario
- Automate a scenario and see it fail
- Write a programmer test and see it fail
- Write enough code to make the programmer test pass
- Refactor to clean up the code
- Manual exploratory testing
- Release to production
Questionsβ
1. Where are we now?β
Show answer
We are at step 6, writing enough code to make the programmer test pass.
Prior to this we began at step 4, automating a scenario and seeing it fail. Then we did step 5, writing a programmer test and seeing it fail.
2. What do we need to do next?β
Show answer
Step 7. We must refactor our code and ensure our programmer tests and scenarios still pass.
Are you satisfied with your solution? Is there anything you would change?
In the next section you'll have a chance to refactor some of the code and learn about step definition arguments.