bdd (behavior driven development)

25
BDD Helder De Oliveira @HelderDOliveira

Upload: helder-de-oliveira

Post on 23-Aug-2014

319 views

Category:

Presentations & Public Speaking


3 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Bdd (Behavior Driven Development)

BDD

Helder De Oliveira

@HelderDOliveira

Page 2: Bdd (Behavior Driven Development)

Waterfall

Análisis

Diseño

Desarrollo

Pruebas

Requisitos

Page 3: Bdd (Behavior Driven Development)

Test First

Análisis

Diseño

Requisitos

Desarrollo Pruebas

Page 4: Bdd (Behavior Driven Development)

Test-Driven Design

Análisis

Diseño

Requisitos

Desarrollo

Pruebas

Page 5: Bdd (Behavior Driven Development)

Test-Driven Design

TDD se centra en pequeños pasos desde dentro hacia fuera, en lugar de especificaciones de negocio

pruebas fallando

prueba pasandorafactorizar

Page 6: Bdd (Behavior Driven Development)

Behavior-Driven Design

Análisis

Diseño

Requisitos

Desarrollo

Pruebas

Page 7: Bdd (Behavior Driven Development)

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

Page 8: Bdd (Behavior Driven Development)

ModeloStory: Returns go to stock

In order to keep track of stockAs a store ownerI want to add items back to stock when they're returned

Scenario 1: Refunded items should be returned to stockGiven a customer previously bought a black sweater from meAnd I currently have three black sweaters left in stockWhen he returns the sweater for a refundThen I should have four black sweaters in stock

Scenario 2: Replaced items should be returned to stockGiven that a customer buys a blue garmentAnd I have two blue garments in stockAnd three black garments in stock.When he returns the garment for a replacement in black,Then I should have three blue garments in stockAnd two black garments in stock

Page 9: Bdd (Behavior Driven Development)

Ej: Concordion

Especificación en formato

HTMLSistema a probar

Fixture que enlaza la especificación con el sistema a probar

Page 10: Bdd (Behavior Driven Development)

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

Page 11: Bdd (Behavior Driven Development)

Herramientas

● junit: http://junit.org/

● Concordion: http://concordion.org/

● Cucumber: http://cukes.info/

● JBehave: http://jbehave.org/

● Jasmine: http://jasmine.github.io/

Page 12: Bdd (Behavior Driven Development)

Proceso simplificado

pruebas unitaria fallando

prueba unitaria pasando

rafactorizar

prueba de aceptaciónfallando

prueba de aceptaciónpasando

Page 13: Bdd (Behavior Driven Development)

DEMO

Page 14: Bdd (Behavior Driven Development)

Demo - pom.xml - dependencia

<dependencies> <dependency> <groupId>org.concordion</groupId> <artifactId>concordion</artifactId> <version>1.4.4</version> </dependency> </dependencies>

Page 15: Bdd (Behavior Driven Development)

Demo - pom.xml - salida <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemProperties> <property> <name>concordion.output.dir</name> <value>target/concordion</value> </property> </systemProperties> </configuration> </plugin> </plugins> </build>

Page 16: Bdd (Behavior Driven Development)

Demo - estructura

Page 17: Bdd (Behavior Driven Development)

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>

Page 18: Bdd (Behavior Driven Development)

Demo - Fixture de Concordionpackage 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); }}

Page 19: Bdd (Behavior Driven Development)

Demo - Usando tablas<table concordion:execute="#result = getTestResult(#a,#b)"> <tr> <th concordion:set="#a">Primer numero</th> <th concordion:set="#b">Segundo numero</th> <th concordion:assertEquals="#result">Resultado</th> </tr> <tr><td>1</td><td>1</td><td>2</td></tr> <tr><td>2</td><td>2</td><td>4</td></tr> <tr><td>3</td><td>4</td><td>7</td></tr> <tr><td>4</td><td>8</td><td>12</td></tr> <tr><td>5</td><td>16</td><td>21</td></tr> <tr><td>6</td><td>32</td><td>38</td></tr></table>

Page 21: Bdd (Behavior Driven Development)

ReferenciasDiferencias entre TDD y BDD

Page 22: Bdd (Behavior Driven Development)

ReferenciasBDD en 5 minutos por Corey Haines

https://vimeo.com/23061155

Page 23: Bdd (Behavior Driven Development)

Kata

Page 24: Bdd (Behavior Driven Development)

Kata

String Calculator BDDhttps://github.com/hemarque/stringcalculator-bdd

Otrashttp://codekata.com/

Page 25: Bdd (Behavior Driven Development)

System.exit(0);

http://www.mundoagil.es

http://about.me/helderdeoliveira