Skip to content
  • Technology
  • Digital transformation

3 minutes on... Behaviour-driven development


by Sarah Finch

What is behaviour-driven development and how does it produce better software?

Behaviour-driven development (BDD) is an approach to building software widely used by agile and DevOps teams to create high quality software, faster.

Its origins lie in a similar methodology called test-driven development, where a test for a particular unit of software is written before the software is actually built. This ensures that the development process is driven by objectives, and the end product fulfils its function.

Some problems with this approach are that a focus on testing doesn't help to inform other aspects of the software development process, such as which features are the most important from a business perspective and should therefore be prioritised. The amount of testing going on (test coverage) can sometimes be pursued as an end in itself, rather than as a means to high quality software. Finally, a knowledge gap can also arise between developers and business teams unfamiliar with the language of software testing and development.

Behaviour-driven development was created by Daniel Terhorst-North as a way of addressing these issues, as well as improving communication and collaboration between business and technical teams to release greater value from software.

BDD provides a methodology for software development and a language to discuss it that both technical and business teams can understand.

Instead of talking about 'tests' it instead focuses on 'behaviours' of a piece of software, describing what it does in certain scenarios. These scenarios should be based around user stories to link software features to business needs. They follow a user story framework: As a [persona]… I [want to] … [So that] … and a 'given, when, then' framework which applies user stories to specific settings.

In BDD, tests are still extremely important, but they are given titles in plain sentences so that everyone can clearly understand their function and see how the software behaves. This provides an opportunity to discuss business value, by asking the question: 'What's the next most important thing the system doesn't do?' BDD therefore helps to identify and prioritise successive features for development.

The language of behaviour-driven development

  • A focus on behaviours, not tests.

  • Based on user stories, As a [persona]… I [want to] … [So that] …
    • For example: As a customer, I want to shop online, So that I don't have to travel to the shop.

  • Scenarios describe how the software should behave in certain settings via the 'given, when, then' framework.
    • In an ecommerce example, this might be: Given the item is in stock when the customer clicks 'add to basket', then the item is added to their basket.
  • Test names must begin with 'should' – this keeps the behaviour of the software focused. In a data input field for customer names, for example, the code might read: testShouldFailForMissingSurname
Sarah Finch's avatar

Sarah Finch


Our recent insights

FAIR Data Principles (1)

FAIR data - what is it and why should you care?

One of our senior data consultants, Dr Alasdair Gray, explains what FAIR data is, who’s using it, why it’s so useful and some common misconceptions around it.

Big Data or Machine Learning — What's best for your organisation?

What's the difference between big data and machine learning, and which should you be using to satisfy your business requirements?

How to get started with low code

When should you consider low code solutions, what are the benefits, and how to begin?