Behavior-driven development (BDD) starts where the user stands. It defines the behavior a user expects, in words the business uses, and builds the software to match, so what gets delivered fits user expectations and business requirements alike. Development, testing and collaboration fold into one user-centric process.
Key concepts of BDD
- User-centric approach: BDD begins with the people who use the software and what they need to get done, and describes each behavior from where they stand: a customer placing an order, a cook marking a dish sold out.
- Collaboration: The owner, the people who use the result and the webmaster agree on the behavior before it is built, in scenarios all of them can read.
- Common language: Behavior is written in a common language, typically plain English, that technical and non-technical people read alike, which makes expectations easier to share and to pin down.
-
Behavior specifications: Scenarios specify how the software should behave in each situation, in a clear, structured Given-When-Then format:
- Given: the starting context, the state of things before.
- When: the action or event that happens.
- Then: the outcome that should follow.
- Continuous feedback: Questions and corrections come back while the work goes on, and a behavior the written scope never named is quoted and approved before it is built.
- Automation: BDD scenarios serve as the basis for automated tests. Run on every change, they fail the moment the software stops doing what a scenario describes. Pure code makes that automation cheap; the lecture What Is a Function? shows why code that returns the same output for the same input is easy to test.
The common language is the concept the others lean on, and the quickest way to see it is to follow one word through a job:
Benefits of BDD
- User-centric development: BDD ties each piece of the work to a need someone named, so the owner can check the software against it.
- One reading of the job: The owner and the webmaster read the same scenarios, so a misunderstanding shows up as a line someone disagrees with, before anything is built.
- Early issue detection: A missing case shows up while its scenario is written, when it costs a question rather than a rebuild.
- Living documentation: The scenarios describe what the software does today, because a scenario that stops being true fails its test.
BDD suits a team that wants to check its software against what its users need, on every change. The next lesson, Principles of behavior-driven development (BDD), turns these concepts into the rules each scenario is held to.