This repository contains two projects based on the concepts from Chapter 3 of "BDD in Action, Second Edition" by John Ferguson Smart:
- An interactive infographic that visually explains the BDD lifecycle.
- A .NET implementation of the "Train Timetables" example from the chapter.
This project includes an interactive, single-page application that visualizes the key concepts of the Behavior-Driven Development lifecycle. It's built with HTML, Tailwind CSS, and Chart.js.
You can view the live, interactive infographic here: View the BDD Infographic
- Clone the repository.
- Open the
index.htmlfile in your web browser.
This project is a practical implementation of the "Train Timetables" example described in the book. The goal of this repository is to demonstrate how to apply BDD and TDD principles using modern tools from the .NET ecosystem.
This project follows the step-by-step development process explained in the book: from defining business requirements using concrete examples (scenarios) to implementing the application logic using unit tests (TDD). The main workflow includes:
- Formulate: Writing executable specifications in the form of Gherkin scenarios.
- Automate: Turning these scenarios into automated acceptance tests.
- Drive Development: Using unit tests to implement the underlying logic that makes the acceptance tests pass.
This example is built using the following tools and frameworks:
- .NET 8: The primary development platform.
- C# 12: The programming language.
- Reqnroll: A modern alternative to SpecFlow for running Gherkin-based BDD scenarios.
- xUnit: The main framework for running both acceptance and unit tests.
- FluentAssertions: A popular library for writing more readable and fluent assertions in tests.
The project is divided into three main parts to clearly separate responsibilities:
TrainTimetables.Domain/: This project contains the core application logic (domain classes) likeItineraryServiceandInMemoryTimetable. It has no dependencies on testing frameworks.TrainTimetables.AcceptanceTests/: This project contains the BDD tests.Features/: The.featurefiles where Gherkin scenarios are defined.Steps/: TheStep Definitionclasses that connect each step of the scenarios to C# code.
TrainTimetables.UnitTests/: This project contains the low-level unit tests written with a TDD approach to drive the implementation of the domain classes.
Follow these steps to run the project and see the test results.
Ensure you have the .NET 8 SDK or a higher version installed on your system. You can download it from the official .NET website.
After cloning the repository, open a terminal or command line in the root folder of the project and run the following command:
dotnet test
This command will automatically discover and run all acceptance tests (Reqnroll) and unit tests (xUnit) across the solution and display the results in the console.
This project is entirely based on the excellent and informative example provided in the book "BDD in Action, Second Edition" by John Ferguson Smart. All credit for the concepts and the development flow belongs to the author and his book. This repository is solely an attempt to implement those concepts using the .NET technology stack.