---
title: Behaviour-Driven Development (BDD)
description: Principles and practices of BDD
type: agent/instruction
tags: [testing, development, methodology, collaboration]
---

{{h1}}Behaviour-Driven Development (BDD)

{{h2}}Core Concept

Focus on system behaviour from user perspective using natural language. Extends TDD with business-readable specifications.

{{h2}}Given-When-Then Format

```
Given [initial context/preconditions]
When [event or action occurs]
Then [expected outcome]
And [additional conditions]
```

{{b}}Example{{b}}:
```
Given a user has items in cart
When they proceed to checkout
Then they should see order summary
And total should include tax
```

{{h2}}Key Principles

- {{b}}Behaviour Over Implementation{{b}}: Describe what system does, not how
- {{b}}Concrete Examples{{b}}: Use real data, not abstractions
- {{b}}Ubiquitous Language{{b}}: Shared vocabulary between technical and business stakeholders
- {{b}}Outside-In{{b}}: Start with user-facing behaviour, work toward implementation
- {{b}}Living Documentation{{b}}: Specifications stay synchronised with code

{{h2}}BDD Process

1. {{b}}Discovery{{b}}: Explore requirements, identify rules and examples
2. {{b}}Formulation{{b}}: Write examples in Given-When-Then format
3. {{b}}Automation{{b}}: Turn examples into automated tests, implement behaviour

{{h2}}Implementation Guidelines

- Use domain language, not technical jargon
- Make scenarios concrete and specific
- Focus on business value
- One action per When clause
- Scenarios should survive refactoring
- Avoid testing internal implementation

{{h2}}BDD vs TDD

- {{b}}Focus{{b}}: Business behaviour vs code correctness
- {{b}}Language{{b}}: Domain/business vs technical
- {{b}}Scope{{b}}: Feature level vs unit level
- {{b}}Direction{{b}}: Outside-in vs inside-out
