Behavior-Driven Development (BDD)

What is Behavior-Driven Development (BDD)?

Behavior-driven development (BDD) is an approach in which business, development and testing agree on a feature's behavior as concrete examples, written in plain Given-When-Then language, that become automated tests.

Updated November 2026 · 3 min read


Behavior-driven development (BDD) is an approach to building software in which the expected behavior of a feature is agreed in concrete examples before any code is written, in language that business people, developers and testers all understand. Those examples are written in a structured format, usually Given-When-Then, and can then be automated so that they become tests. The result is a single description of what the system should do that serves as specification, test and documentation at once.

Dan North developed BDD in the early 2000s while coaching teams in test-driven development. He noticed that developers struggled with the word "test": they did not know where to start, what to test or what to call their tests. Reframing tests as descriptions of behavior helped, and North built JBehave, a Java framework, around the idea. He introduced it publicly in a 2006 article, "Introducing BDD." Business analyst Chris Matts helped shape the Given-When-Then format, and Aslak Hellesøy's Cucumber, released in 2008, made the plain-language scenario format widely popular.

How BDD Works

  1. Discovery. Before work on a story begins, a product owner, a developer and a tester, often called the "three amigos," discuss it and agree on concrete examples of how it should behave, including edge cases. Many teams use example mapping, a short workshop that lays out rules, examples and open questions on cards.
  2. Formulation. The agreed examples are written as scenarios in a structured, readable form, usually the Gherkin language used by Cucumber and similar tools.
  3. Automation. Developers connect each step of each scenario to code that drives the application and checks the result. The scenarios fail at first, then pass as the feature is built.

North and others stress that the conversations in the first step are the main point. Teams that skip them and only use the tools tend to get verbose tests and few of the benefits.

Given-When-Then

Each scenario has three parts: the context, the action and the expected outcome. A scenario for a hypothetical banking app might read:

  • Given a customer's account has a balance of $100
  • When they request a withdrawal of $150
  • Then the withdrawal is declined
  • And the balance remains $100

Because the scenario uses business terms rather than technical ones, a product manager can check that it is right and a developer can automate it. Scenarios are grouped into feature files that describe each capability.

BDD, TDD and ATDD

TDDBDDATDD
Main questionDoes this unit of code work as the developer intended?Does the system behave as everyone agreed it should?Does the feature meet its acceptance criteria?
Written byDevelopersBusiness, development and testing togetherBusiness, development and testing together
LanguageProgramming languagePlain, structured business languageVaries, often tables or plain language
LevelUnits of codeFeatures and user-visible behaviorFeatures and user stories

The boundaries are blurry. BDD grew out of TDD, and acceptance test-driven development is close enough to BDD that many practitioners treat them as the same thing with different emphasis. Teams commonly use BDD scenarios for features and TDD for the code underneath.

Benefits

  • Shared understanding. Misunderstood requirements are one of the most expensive sources of rework. Agreeing concrete examples up front exposes gaps and disagreements before code is written.
  • Living documentation. Automated scenarios describe what the system actually does, and they fail when behavior changes, so unlike a requirements document they cannot quietly go out of date.
  • Tests that reflect value. Scenarios focus on outcomes users care about rather than internal details.
  • A clear definition of done. A story is finished when its scenarios pass.

An Example

Consider a hypothetical insurance company adding online cancellation of policies. In a 30-minute example mapping session, the product owner states the main rule: customers get a pro-rated refund. The tester asks what happens if a claim has been made this year, and the product owner realizes no one has decided. The developer asks about policies cancelled on the day they start. The team leaves with four rules, nine examples and one question for the claims department. The examples become nine scenarios. When the feature ships, the claims edge case is handled correctly, and the scenarios remain as an accurate description of cancellation rules for whoever touches the code next.

Common Pitfalls

  • Tools without collaboration: developers writing Gherkin alone after the fact, which adds overhead and none of the shared understanding.
  • Scenarios written as scripts of clicks and field entries instead of business behavior, which makes them brittle and hard to read.
  • Too many scenarios at the UI level, producing a slow, fragile suite. Many scenarios can be automated below the interface.
  • Letting the suite rot, with failing or skipped scenarios that no one trusts.

BDD scenarios often start from a user story and its acceptance criteria, and once automated they run in the CI/CD pipeline with every change.