+3 votes
176 views
in Web development by (242k points)
reopened
Behavior-driven development in agile software development

1 Answer

+4 votes
by (1.6m points)
edited
 
Best answer

What is behavior-driven development?
How exactly does behavior-driven development work?
Behavior-guided development: a practical example
What sets BDD apart from other testing methods?

image

Behavior-driven development in agile software development

A few years ago, testing the functionality of a final software product was a task that could keep a quality department busy for weeks. Nowadays, however, thanks to automatic tests, a few clicks are enough to find out whether a complex application does its job or not. In this sense, behavior-driven development (BDD), or behavior-guided development, is an increasingly popular technique. It is a form of agile software development that emerged from test-driven development (TDD) and is considered a logical extension of it. Unlike what happens in TDD, in BDD, the software in question is analyzed from the user's perspective, an approach that favors a more holistic design and that facilitates the joint work of developers, quality managers and customers..

Index
  1. What is behavior-driven development?
  2. How exactly does behavior-driven development work?
  3. Behavior-guided development: a practical example
  4. What sets BDD apart from other testing methods?

What is behavior-driven development?

As the complexity of software applications increases , new methods of quality assessment and test management emerge. These procedures are essential to ensure that the software works reliably and identify bugs from the outset. One of these techniques, already widespread for some time, is test-driven development (TDD) , with which developers create, in parallel to the software itself, the corresponding unit or system tests . However, in software design , it is also advisable to involve other team members or interested persons, who do not necessarily have knowledge of programming codes. The behavior-driven development (BDD) or driven development behavior precisely solves this problem.

The agile development software allows all project participants determine the features they want to see in an application before the programmer starts writing the source code. These specifications are expressed in easy-to-understand language, so that even the customer for whom the software is made can actively participate in its design. In this way, the BDD promotes joint work between the different areas of the project and the sharing of responsibility. If applied properly from the start, this form of agile software development avoids misunderstandings and results in a high-quality product at best..

How exactly does behavior-driven development work?

As can be guessed from its own name, behavior-driven development is guided by the behavior that you want to obtain from the final software . Thanks to the so-called ubiquitous language , a kind of common language, even non-experts can describe specific behaviors. The ubiquitous language was born in the domain of domain-driven design (DDD, domain-driven design ), a methodology that, like BDD, focuses on product application areas. Both approaches take into account all the areas involved in the software project and interconnect them beyond frameworks , programming languages ​​or specific tools, all thanks to the ubiquitous or common language.

However, behavior-driven development cannot totally do without tools and frameworks: certain rules must be respected so that the test cases that are defined can be translated into an executable programming language. For this reason, the specifications in BDD are not expressed as plain text, but, with the help of BDD tools such as JBehave, Cucumber or Behat , conform to a certain structure that makes their correct implementation possible. However, handling these tools is much easier than learning a conventional programming language. Here's the structure that is normally followed in behavior-guided development:

  • First, a requirements analysis is performed in which the tasks, objectives and functions of the software are specified . In this phase, the company asks (or asks customers) what the software should be able to do .
  • Once all the functions have been identified , they are described in the form of predefined scenarios: the goal is to think of all possible situations in which the software should react by giving a concrete response.
  • The next step is to establish the response expected in each scenario or situation using a given-when-then type scheme , that is, given-when-then : given describes the state of the software before the test; when it describes the action during the test and then it describes the state of the software after the test.

Depending on which BDD tool is used, the vocabulary used may vary slightly. These tools are available for the most common programming languages, such as Java, JavaScript, Python, or Ruby..

Behavior-guided development: a practical example

Imagine that you want to develop an intuitive online store that stores the user data of each customer who registers: thus, customers can simply log in and avoid having to re-enter their personal data. In Gherkin , a widely used programming language used in the BDD Cucumber tool, the corresponding syntax would have the following form:

  Funcionalidad: un cliente ya registrado quiere iniciar sesión en su cuenta de usuario. Escenario: el cliente introduce correctamente sus datos de acceso a la cuenta. Dado que tengo una cuenta de usuario activa Y me encuentro en la página de inicio Cuando teclee mi dirección de correo electrónico en el campo correspondiente Y teclee la contraseña asociada en el campo correspondiente Y haga clic en la tecla de iniciar sesión Entonces debería iniciarse mi sesión  

The example above shows that various conditions can be added using the AND element , which allows you to create more complex test cases.

What sets BDD apart from other testing methods?

When testing software , behavior-driven development is primarily guided by the question of how : stakeholders want to know how to check the behavior of a code, not its implementation. In the so-called module tests, on the other hand, it is a question of checking if a specific code unit is being implemented correctly. These test procedures allow you to quickly detect bugs , so they are based on the question what . On the other hand, the question of what if? gets its answer thanks to test-driven development , which tests the process of executing the tests, which can also include module tests or other types of tests.

Note

In addition to the module tests, there are also functional and integration tests, which are much more complex since they analyze the interaction between different parts of the system and the functionality of the entire software .

The following table summarizes the advantages and disadvantages of behavior-driven development :

Advantage Drawbacks
Ideal for beginners thanks to the ubiquitous language, which requires no prior knowledge. Poorly written specs make it difficult for developers to work.
Better communication between developers, stakeholders and quality managers. Because it integrates various stakeholders, the development process takes longer.
Test cases are living documentation that can be easily adapted. Converting to a BDD workflow takes added effort if you use legacy code.
The priority is the user's comfort when operating the software.  

Although the different test methods can be applied one by one, the quality of the software improves considerably if a combination of several is used. The BDD helps to identify the best approach to test writing, while the TDD takes care of achieving high test coverage.


...