BDD (Behaviour Driven Development) is a practice popularized by Dan North in 2003, and derived from TDD (Test Driven Development), to which it is complementary.
Why use BDD? Precisely to address the common problems with specifications in Agile mode:
BDD is therefore an Agile practice aimed at synchronizing the various players developing a feature with what it is supposed to do. The aim of BDD is to design acceptance tests, illustrating the functionality’s behavior, using methods such as the 3 amigos or example mapping. The BDD approach is generally carried out in 3 stages: discovery, formulation and automation.
The players are synchronized using co-designed examples that illustrate the functionality’s behavior: this is the discovery of the US, often achieved thanks to the meeting of the 3 amigos (customer, developer and tester profiles), which provides a common understanding of the need, and enables acceptance scenarios to be written to validate the acceptance criteria.
These examples are formulated using a common language, Gherkin, easily understood by the different profiles of the 3 amigos. This Gherkin language is formatted to write structured tests in a natural language, and a priori understandable by all. Gherkin tests are written with the 4 basic elements: GIVEN / WHEN / THEN … AND (GIVEN a certain context, WHEN I perform an action, THEN I have a result1 AND a result2).
From this structured (and formatted) formulation of the functionality’s behavior, it is possible to integrate these examples into a software tool, like Cucumber for example, which will interpret this Gherkin language to run automated acceptance tests, adapted to these examples. This is the automation stage.
BDD is now used in many companies to test the behavior of certain functionalities in close collaboration with users. But even if BDD is used to achieve a common understanding of needs, there are still a number of confusions surrounding this Agile practice, which can lead to certain abuses. What are they?
Before the sprint, the BDD practice consists, through discovery, in validating a common understanding of the requirement by all the players involved. This understanding is formulated through examples, acceptance criteria and acceptance scenarios, which are then implemented in a tool for the design and execution of automated tests.
Applying the various stages of this approach will help to combat BDD drift and, above all, the confusion currently encountered over the various terms surrounding the BDD concept.