Development

July 8, 2015

Taking Behavior Driven Development (BDD) for a spin: What it is and how to use it

Behavior Driven Development (BDD) is a software development process that emerged from as a shift in the thinking and practices associated with TDD (Test Driven Development) and ATDD (Acceptance Test Driven Development).

The brainchild of Dan North, BDD is an agile methodology with a greater focus on user stories and automated acceptance testing that synthesises and eliminates the friction between the two approaches previously mentioned, making them more accessible and effective for development teams.

What is Behavior Driven Development?

At the heart of BDD is the stipulation that unit testing must be specified in terms of the behaviour that the system is expected to demonstrate when it is tested. This behaviour is prioritised according to its business value for the client.

In fact, one of the biggest benefits of BDD is that it unites business interests with technical requirements through the use of a simplified common vocabulary to describe system behaviour that reduces the risk of communication between team members with different backgrounds.

Besides implementing a ubiquitous language, other hallmarks of BDD include:

  • A set of specialised software tools based on BDD notation supporting development;
  • A focus on the user stories, also referred to as scenarios and situations, which clearly delineate the behaviours that contribute successfully to the business outcomes.
  • An outside-in mentality that applies the techniques on a higher level of abstraction: testing the intent of them whole system versus just the functioning of a single piece of code.

How does BDD work?

The most important feature of BDD is that test methods in a class are given expressive names that clearly describe what they’re meant to do using the following template: testShouldFailFor…

This notation helps you keep in mind that there are multiple reasons why test fails, including problems in the system, or a mistake in the test case itself.

The test cases or user stories themselves also follow a very simple textual format, which consists of a title and several sentences that describe what happens in each scenario included in the story.

Example:

Story: Check the latest date due in a list of development tasks

 

In order to determine whether the project will be finished on time

As a project manager

I want to see the status of all development tasks

 

Scenario 1: Sorting tasks by date due

Given a list of all assignments and tasks

And their status

When I click on the ‘Sort by date due’ button

Then I should be able to sort them all by date due

The language used in the previous user story is called Gherkin and it is a keyword-based, line-oriented language that’s easily supported by automation tools for the most popular programming languages.

Wrap up

BDD has a significant impact on the project delivery since it encourages development teams to become more business-aware and engage more easily with their business colleagues or commercially-oriented external stakeholders.

Behavior Driven Development can be easily integrated within Scrum teams since its principles harmonise closely with those the team members are already accustomed to. As such, BDD is an excellent method that can be used to resolve communication problems in a project, and prioritise the backlog so that’s more in sync with the commercial interests of the client.

Share article