Key takeaway
- Behaviour-driven development turns shared examples into automated tests. Learn the three practices, Given-When-Then, tools and how AI agents fit in.
Behaviour-driven development (BDD) is a way of building software in which developers, testers and business people agree on concrete examples of how the system should behave, write them in a shared language and turn them into automated tests. The examples double as documentation that is checked against the running system.
This guide is for engineering leads, testers, product owners and architects who want to adopt behaviour-driven development without turning it into a tool exercise. It covers the three practices, the Given-When-Then format, how BDD relates to test-driven development, the common tools, and where AI agents fit.
What is behaviour-driven development?
Cucumber's BDD guide describes BDD as the software development process Cucumber was built to support. It helps teams close the gap between business and technical people by building shared understanding, working in small iterations and producing documentation that is automatically checked against the system's behaviour. It adds that BDD does not replace your existing agile process, it enhances it, and that the real goal is valuable, working software.
The idea has a clear origin. In Introducing BDD, Dan North explains that he saw people learning test-driven development keep asking where to start, what to test and what to name tests. Replacing the word test with behaviour answered many of those questions, because each test became a sentence describing the next behaviour the developer cared about. He and Chris Matts later applied the same thinking to requirements and wrote a story's acceptance criteria as scenarios.
What are the three practices of BDD?
| Practice | Question it answers | What the team does |
|---|---|---|
| Discovery | What could the system do? | Holds structured conversations about real-world examples from the user's point of view, which also exposes low-priority work that can wait |
| Formulation | What should it do? | Writes the agreed examples in a format people and computers can both read, using Gherkin |
| Automation | What does it actually do? | Connects each example to the system as an automated test that fails until the behaviour is built |
Cucumber says to start with discovery. A team that skips straight to writing scenarios gets the syntax of BDD without the shared understanding that makes it worthwhile.
What does the Given-When-Then format look like?
The Gherkin reference defines the keywords. A Feature groups related scenarios, and a Scenario (also called an Example) is a concrete example of a business rule made of steps. Given sets the initial context, When describes the action and Then states the expected outcome. And and But continue a step, Background holds steps shared by every scenario in a feature, and a Scenario Outline runs one template once for each row of an Examples table.
Feature: Cash withdrawal
Scenario: Withdraw within the balance
Given an account holding 100
When the customer withdraws 40
Then the account holds 60
Each step's text is matched to a block of code called a step definition, and Cucumber runs the steps in order. Because the scenarios are plain text, a product owner can review them without reading code.
How is BDD different from TDD and ATDD?
| Approach | Main focus | Who reads the tests |
|---|---|---|
| TDD | Code-level tests written before the code | Mainly developers |
| BDD | Examples of system behaviour in a shared language | Developers, testers and business stakeholders |
| ATDD | Acceptance criteria agreed before development | The whole team |
BDD grew out of TDD rather than replacing it, so teams often use both. Our guides to acceptance test driven development tools, TDD in Python, TDD for Java, TDD with React JS and database unit testing show the test-first side in more depth.
Which tools support BDD?
Scenarios live in text files with the .feature extension, which any editor can open and BDD tools can run. Cucumber supports several programming languages. JBehave is a Java framework, and Dan North describes writing the first version in 2003 as a JUnit replacement built on behaviour vocabulary. Behat is a PHP framework. Check each project's own documentation for current versions, because tool ecosystems change.
Wired into a CI/CD pipeline, the automated examples give rapid, repeatable feedback. Cucumber notes that this reduces the burden of manual regression testing.
What goes wrong when teams adopt BDD?
- Scenarios become technical: if steps describe clicks and fields instead of business outcomes, business readers stop reviewing them.
- Discovery is skipped: developers write the scenarios alone, so the shared understanding never forms.
- Specifications are over-detailed: scenarios that pin down every value are costly to change when the feature evolves.
- Tool first, conversation second: Cucumber itself says there is much more to BDD than just using Cucumber.
How do AI agents change behaviour-driven development?
Agents can help draft scenarios from a conversation, propose missing edge cases for a feature, or write step definitions for a human to review. Scenarios also work as a guide for agents that write code: an agent's change is accepted only when the agreed examples pass. The conversation itself still needs people, because deciding precisely what to build is a judgement about the business. As more of the code is generated, readable, executable examples become the place where intent is recorded.
For teams building and testing agents, ElixirClaw is the AI agents computing platform from XenonStack. See also our view of generative AI in software development.
What should you do first?
- Pick one feature with real business rules and hold a short discovery conversation with a product owner, a developer and a tester.
- Write three to five scenarios in Given-When-Then form and ask a business reader to confirm them.
- Automate those scenarios with a tool that fits your language.
- Run them in your pipeline on every change.
- Review after a sprint: keep the scenarios people actually read, and simplify the rest.
To map one decision your agents make, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.
Next Steps for Implementing Behavior-Driven Development
Talk to our experts about implementing Behavior-Driven Development (BDD) and how industries and departments leverage Agentic Workflows and Decision Intelligence to become more decision-centric. Use AI to automate and optimize IT support and operations, improving efficiency and responsiveness.
Frequently asked questions
What is the difference between BDD and TDD?
TDD writes code-level tests before the code, mainly for developers. BDD grew out of TDD and describes system behaviour as examples in a shared language that business people can read as well.
What is Given-When-Then?
It is the structure of a BDD scenario. Given sets the initial context, When describes the action and Then states the expected outcome.
What are the three practices of BDD?
Discovery, formulation and automation. Teams discuss examples, write them in Gherkin, then connect each one to the system as an automated test.
Do you need Cucumber to do BDD?
No. Cucumber's own guide says there is much more to BDD than just using Cucumber, and tools such as JBehave and Behat also read scenarios written in feature files.
Can AI agents write BDD scenarios?
They can draft scenarios and step definitions for review, but the discovery conversation and the decision on what to build still need people.
Ready to put AI agents to work? See an ElixirClaw demo: the agentic OS to build, orchestrate and govern AI agents across your enterprise systems.
Explore the XenonStack platform family: ElixirData · ElixirClaw · ElixirHub · NexaStack · MetaSecure · Neural AI · AgentGRC · AgentSRE · AgentAnalyst · AgentInstruct · AgentRAI · AgentScrum · AgentSearch · AgentForce · AI Aviator · SAIF Aviator · CohortIQ · XenonStack AI · XenonStack UAE