Behavior-driven development combines the general techniques and principles of TDD with ideas from domain-driven design and object-oriented analysis and design to provide software developers and business analysts with shared tools and a shared process to collaborate on software development
5. Test-Driven Design
TDD se centra en pequeños pasos desde
dentro hacia fuera, en lugar de
especificaciones de negocio
pruebas fallando
prueba pasandorafactorizar
7. Behavior-Driven Development
BDD se centra en los mejores hábitos de
TDD:
● Va desde fuera hacia dentro
basándose en objetivos de negocio
● Usa ejemplos descriptivos
● Se centra en el lenguaje ubicuo
8. Modelo
Story: Returns go to stock
In order to keep track of stock
As a store owner
I want to add items back to stock when they're returned
Scenario 1: Refunded items should be returned to stock
Given a customer previously bought a black sweater from me
And I currently have three black sweaters left in stock
When he returns the sweater for a refund
Then I should have four black sweaters in stock
Scenario 2: Replaced items should be returned to stock
Given that a customer buys a blue garment
And I have two blue garments in stock
And three black garments in stock.
When he returns the garment for a replacement in black,
Then I should have three blue garments in stock
And two black garments in stock
10. Beneficios
● Guía precisa de conversación entre el
equipo y el product owner
● Plantillas como given-then-when son
muy cercanas a las conversaciones
diarias
● Las especificaciones son ejecutables
17. Demo - Especificación de Concordion
<html xmlns:concordion="http://www.concordion.
org/2007/concordion">
<head>
<title>Configuracion</title>
</head>
<body>
<h1>REQ-001 Config</h1>
<p>
Provee las características para sumar dos enteros. Ejemplo:
<span concordion:set="#a">2</span> mas
<span concordion:set="#b">5</span> debe dar
<span concordion:assertEquals="getTestResult(#a,#b)"
>7</span>.
</p>
</body>
</html>
18. Demo - Fixture de Concordion
package exampleapp.spec.config;
import exampleapp.Configuration;
import org.concordion.integration.junit4.ConcordionRunner;
import org.junit.runner.RunWith;
@RunWith(ConcordionRunner.class)
public class ConfigTest {
public int getTestResult(int a, int b) {
Configuration conf = new Configuration();
return conf.addTwoIntegers(a, b);
}
}