Skip to content
  • Technology
  • Digital transformation

3 minutes on... Behaviour-driven development

what-is-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

TPXimpact

Contact Sarah

Our recent insights

Shaping Product And Service Teams

Shaping product and service teams

How cultivating product and service teams to support the needs of the entire product lifecycle can ensure brilliant delivery.

Building ‘The Chatbot’ - Our experience with GenAI

Learn how we harnessed to power of Generative AI to build our very own chatbot.

How digital transformation can improve access to justice

Jay Bangle discusses the power technology has to open up justice services to everyone