Introduction to Behavioral Driven Development

07 april 2021 om 10:00 by ParTech Media - Post a comment

Software development is hard! Developers have to create applications and test them ruthlessly. If it has no errors, they have to launch it and take it to live. But they have one more task - developing the right functions/ features that is important for the business.

Product owners need developers to work on concepts that would only move the business forward. But they find these developers working on features that don’t have any association with their original requirement.

There is a massive disconnect between developer and product owners. And to bridge this gap, we have behavior driven development. In this post, let us understand what is behavior driven development and why it is so useful.

Table of Contents

  1. What is behavior driven development?
  2. Why use behavior driven development?
  3. Three stages of BDD
  4. How do you successfully implement BDD?
  5. Verdict

What is Behaviour driven development?

Developers used to work with a test driven development methodology. Test-driven development is a concept where a developer creates a test and writes a piece of code to pass that test. If he/she passes the test, that piece is implemented in the software. If the test isn’t passed, it’s back to the drawing board.

But here’s where everything goes wrong. This method used to work in a time when immediate feedback was not possible from customers. This methodology worked in a time when the world moved a bit slow (metaphorically speaking).

But now we have access to so much data from so many test points that this methodology seems meaningless. Why test a feature when the end-user doesn’t even want it? Moreover, a test-driven methodology also causes a communication gap between the development team and the management team. They have no clue about what the developers are currently working on at the moment. All these limitations paved the way for Behaviour Driven Development or BDD.

Behaviour driven development is a way to make sure that your software behaves the way you want it to. More specifically, it is a development methodology where the software behaves the way the end-users want it to. It gives a solid framework for running tests on the most required features of a product.

Moreover, it gives the management team and the development team a solid foundation to communicate with each other.

Why use behaviour driven development?

The answer is quite simple: To add features that would make the company profitable. With TDD (Test Driven Development), your development team is focused on running tests without any goal or direction. They would just work on the features they think are ‘cool’ or something the product “needs right now”.

But a BDD (Behaviour Driven Development) shifts the perspective of what the developer thinks to what the customer wants. It gently breaks the bubble the developer is living in and gives them a way to get feedback. BDD brings the development team and the management team together. It builds a bridge between them and makes seamless communication possible.

As we’ve already stated above, the core aim of BDD is to make sure the developers work on the most important functions of the application on priority.

Three stages of BDD

The three stages of BDD are -

Discovery

This usually involves a meeting between heads of different departments like design, development, marketing, sales and management. They use data to collectively discuss how their application is working and what they need to work on. This stage breaks down any myths and wrong assumptions within each team. This stage helps them understand the real needle mover features of their application. This stage also helps them form a solid understanding of what needs to be worked on priority. This is the most important step in the Behaviour Driven Deployment methodology. It’s safe to say that this step serves as the foundation of all the other steps combined.

Capture

When the discovery sessions are taking place, the development team and the business team take notes of the key points. They identify the key features and translate them into a set of “ Given When Then” statements. These statements help everyone understand the basic functions that need to be fulfilled or created. This step makes sure that all teams are on the same page with respect to the most important features.

Automation

Once the development and all the other business teams have accepted the key points, development starts around. The Development team uses the TDD approach to create and run tests for their software. The business team supplies them with a list of scenarios and they are used as a reference for these tests. The testing team aligns the tests to match the listed scenarios.

This way the development team can be completely sure that they are only developing what the customers want. Thus the chance of rework and any unwanted features are completely removed from the equation.

How do you successfully implement BDD?

Behaviour Driven Development is really helpful for designing products and features that end-users want. But this is only possible when the instructions from the business team are on-point. Here are 2 steps that constitute a successful BDD strategy -

User story

It explains what a user wants when he/she performs a certain action on the application. The framework goes something like this.

As a (role of the users)

I would like (the feature I want)

So that (the benefit I would get)

Once you have set this story, it becomes easier for the development team to come up with a solution.

Given When Then statements

Given (a specific context)

When (a specified action is carried out inside the application)

Then (a particular action or a set of actions occur inside the application)

Combining this with the user story gives the developer a true and well- defined goal to work towards. Here is an example scenario of a user story and “ Given When Then “ statements in real-life application features

Scenario: User wants a picture to zoom in when they double tap on it

Here’s what the user story will look like -

As your application’s user

I would like the photos to zoom in and make it easy to read the text

When I double click on the photo

Here’s what the Given When Then statement would look like -

Given: A user is scrolling through a bunch of photos

When: The user double clicks on a photo

Then: The photo will zoom up

Verdict

The Behaviour Driven Development methodology should allow the development team to work efficiently. It must ensure that the development team actually works on the top priorities of the business. In an ever-changing world moving at lightning pace, BDD will save time, resources and pave the way for a successful application.

Nieuwste