💳 Secure Payment

Full-Service Web & Software Agency · Klamath Falls and Redding

Introduction to behavior-driven development (BDD)

Work with Sean

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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:

One word from the owner to the test Four rows joined by arrows. The owner says the brisket sold out. The scenario says Given "Brisket" sold out. The Redux Toolkit action is itemSoldOut. The test is named for the scenario. The owner’s words carry unchanged into the code. ownerthe brisket sold outscenarioGiven "Brisket" sold outactionitemSoldOuttestnamed for the scenario
One word, four places. The owner’s “sold out” rides the violet arrows to the scenario, the action and the test without a translation, so each reader can find it in the others.

Benefits of BDD

  1. User-centric development: BDD ties each piece of the work to a need someone named, so the owner can check the software against it.
  2. 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.
  3. Early issue detection: A missing case shows up while its scenario is written, when it costs a question rather than a rebuild.
  4. 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.

Copyright Sean Paul Payne Dinwiddie
All Rights Reserved