# Behavior-Driven Development (BDD)

> Writing features as Given, When, Then lines. The lines also run as tests.

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** BDD, Behaviour-Driven Development, Gherkin, Cucumber (Testing)

## Think of it like

Think of it like writing the rules of a game in plain words first. Then everyone plays it the same way.

## Definition

Behavior-driven development is a way to describe a feature in plain sentences before coding it. Each example is written as Given, When and Then. Given sets the scene, When is the action, and Then is the result. Tools like Cucumber turn these sentences into tests that run. People who do not code can read and agree on them.

## Example

Emma runs a shop, and Jack writes the code. They write the checkout rules together as Given, When, Then lines. Jack is done when every line passes.

## Example code

```gherkin
Scenario: Pay with a valid card
  Given a cart with one mug
  When I pay with a valid card
  Then I see "Thank you"
```

One scenario in plain words, which a tool can run as a test.

## Why it matters

The people who want the feature and the people who build it agree first. Then nobody codes the wrong thing.

## Common mistake

Writing scenarios about buttons and clicks. Write what the user wants, not how the screen works.

## Three principles

- **Plain words.** Anyone on the team can read it.
- **Given, When, Then.** Scene, action, result.
- **Runs as a test.** The sentences are checked.

## Related terms

- [Test-Driven Development (TDD)](https://learn.benibix.com/term/development/test-driven-development)
- [Acceptance Test](https://learn.benibix.com/term/development/acceptance-test)
- [Arrange-Act-Assert (AAA)](https://learn.benibix.com/term/development/arrange-act-assert)
- [User Story](https://learn.benibix.com/term/business/user-story)

## Told apart from

- [TDD vs BDD](https://learn.benibix.com/compare/test-driven-development-vs-behavior-driven-development): Test-driven development starts with a failing test in code, then the code that makes it pass. Behavior-driven development starts one step before that. The team writes plain Given, When, Then lines first, and those lines run as tests too.

![On the left, a developer's tests ask: does the code work? On the right, acceptance tests ask: does it do what was asked? Under the right side, a scenario card reads Given a cart with one mug, When I pay with a valid card, Then I see Thank you. At the far right, user acceptance testing, lit up, shows real users trying the app and signing it off before release.](https://learn.benibix.com/diagrams/dev3-acceptance.svg)

---

Source: https://learn.benibix.com/term/development/behavior-driven-development
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
