Infrastructure as Code Best Practices with Terraform for DevOps
João Victor Alhadas | Dec 17, 2024
In this complete guide to Behavior-Driven Development, we’ll answer all your questions about this framework so you can understand all the benefits of BDD to start using it.
Throughout this article, you’ll find:
BDD stands for Behavior-Driven Development.
Originally created in 2003 by Dan North, it is known to be an Agile approach to software development and it is emergent in this industry.
It aims to do exactly what the title suggests: lead your development driven by behavior.
BDD can be defined as a technique that encourages collaboration among developers, quality assurance, and business analysts in a software project.
Dan North himself developed the first automated BDD testing framework in Java: JBehave. And after that, came RSpec and Cucumber.
Behavior-Driven Development actually began as an evolution or complement for TDD (Test Driven Development).
Basically, TDD proposes the elaboration of simple tests before the code definition.
But what to test and what to evaluate?
Here comes the BDD. The main goal of BDD is to bring non-technical people to approach how to understand and define the tests.
In fact, tests are not the main purpose of BDD. Practicing BDD means we’ll specify and execute tests, but the main purpose is to achieve business goals and customer outcomes according to the application level.
One of the biggest problems that a development team faces nowadays is communication.
It is uncommon that a business analyst would ask a task for devs using technical language, because the analyst will be mainly worried about what the customer expects, and not about what technology the developers need to use.
BDD helps simplify communication using scenarios described by the customer or analyst, and those become easily understood by the whole team.
The core idea of BDD is that no one person or field has the full answer to anything.
Sometimes, there is a “Specification Workshop”, where the Product Owner, Quality Assurance and Developers meet and discuss the requirement in the form of specification.
They are also called “The Three Amigos”, and are made up of at least one person from the following 3 areas: Business, Development, and Testing.
Business professionals bring customer requirements and business needs.
Developers know all the technical requirements and software needs, so they know how easily or hard the stories can be implemented. Testers identify edge cases, obstacles, and gaps in the stories.
Usually, BDD is divided into three phases, which are:
The main BDD structure is defined by at least 3 words: Given, When, and Then.
Planning and developing through examples is one of the key concepts of BDD. Giving real case scenarios of what you should expect from the product can make everything easier for everyone.
So let’s see an example:
Feature: Money transfer
Here we are describing money transfers. We have detailed the scenarios and if you have noticed we have predicted a case where the behavior was not concretized.
We have also taken care of making everyone in the project understand what exactly the term account means. Considering that you will find more complex terms eventually, this needs practicing.
Check more BDD Examples: How to Develop Tests for a Pokédex Using BDD
Behavior-Driven Development is very useful for agile projects.
Mainly because we already know that agile projects are going to need several updates, and BDD helps the project stay in line.
Behavior-Driven Development documentation has helped the whole team stay aligned with the business updates, which brought faster development with a minor amount of bugs.
It also helped to bring the development team to the customer/business specification closer.
This way, we could work directly toward the defined business acceptance criteria by the BDD structure.
Mapping BBD scenarios before developing helped us develop in a test-oriented way, which is similar to TDD.
This way, we could test the software from the beginning of the project, while also testing the case uses, finding misunderstandings, edge cases, and polishing acceptance criteria.
A person who loves to see others happy and change the world for better. Lover of pop culture and fantasy world. In addition to technology, enjoys studying philosophy, psychology and magick.