bdd (behavior driven development)

Post on 23-Aug-2014

323 Views

Category:

Presentations & Public Speaking

3 Downloads

Preview:

Click to see full reader

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

BDD

Helder De Oliveira

@HelderDOliveira

Waterfall

Análisis

Diseño

Desarrollo

Pruebas

Requisitos

Test First

Análisis

Diseño

Requisitos

Desarrollo Pruebas

Test-Driven Design

Análisis

Diseño

Requisitos

Desarrollo

Pruebas

Test-Driven Design

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

pruebas fallando

prueba pasandorafactorizar

Behavior-Driven Design

Análisis

Diseño

Requisitos

Desarrollo

Pruebas

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

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

Ej: Concordion

Especificación en formato

HTMLSistema a probar

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

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

Herramientas

● junit: http://junit.org/

● Concordion: http://concordion.org/

● Cucumber: http://cukes.info/

● JBehave: http://jbehave.org/

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

Proceso simplificado

pruebas unitaria fallando

prueba unitaria pasando

rafactorizar

prueba de aceptaciónfallando

prueba de aceptaciónpasando

DEMO

Demo - pom.xml - dependencia

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

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>

Demo - estructura

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>

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); }}

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>

ReferenciasDiferencias entre TDD y BDD

ReferenciasBDD en 5 minutos por Corey Haines

https://vimeo.com/23061155

Kata

Kata

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

Otrashttp://codekata.com/

System.exit(0);

http://www.mundoagil.es

http://about.me/helderdeoliveira

top related