May the feature be with you

Post on 13-Apr-2017

95 views 0 download

Transcript of May the feature be with you

May The Feature Be With You

#bdd

shoun.ichida@viseo.comShoun ICHIDA

@ishoun

#JUGToulouse

Behavior Driven Development? ?

?

??

?

qu’est-ce que c’est ?

➡ Une méthodologie de développement

3

qu’apporte-t-elle ?

➡ Une meilleure compréhension du besoin

4

BesoinCritères

d’acceptation

Tests d’acceptation

Développement

Equipe métier

Equipe projet

➡ Un complément au Test Driven Development (TDD)

5

TEST QUI RÉUSSITTESTQUI ÉCHOUE

Refactoring

TDDTest

d’Acceptation

qu’apporte-t-elle ?

Solutions

Le Gherkin

7

Given

When

Then

Scenario:Luke succeed to destroy the death star

"Luke" is flying an X-wing

He drops his torpedoes

The death star should be destroyed

Feature: Destroy the death star

Rebels should be able to win the warAnd

Le Gherkin

7

Given

When

Then

Scenario:Luke succeed to destroy the death star

"Luke" is flying an X-wing

He drops his torpedoes

The death star should be destroyed

And His vessel has torpedoes

Feature: Destroy the death star

public class RecipeStepdefs { @Given("^\"([^\"]*)\" is flying an X-wing$") public void userIsFlyingAnXwing(String user) throws Throwable { // Your test goes here }

public class RecipeStepdefs { @Given("^\"([^\"]*)\" is flying an X-wing$") public void userIsFlyingAnXwing(String user) throws Throwable { // Your test goes here } @When("^He drops his torpedoes$") public void heDropsHisTorpedeos() throws Throwable { // Your test goes here } @Then(« ^The death star should be destroyed$") public void theDeathStarShouldBeDestroyed() throws Throwable { // Your test goes here }}

Cucumber-jvm

8

public class RecipeStepdefs { @Given("^\"([^\"]*)\" is flying an X-wing$") public void userIsFlyingAnXwing(String user) throws Throwable { // Your test goes here }

public class RecipeStepdefs { @Given("^\"([^\"]*)\" is flying an X-wing$") public void userIsFlyingAnXwing(String user) throws Throwable { // Your test goes here } @When("^He drops his torpedoes$") public void heDropsHisTorpedeos() throws Throwable { // Your test goes here } @Then(« ^The death star should be destroyed$") public void theDeathStarShouldBeDestroyed() throws Throwable { // Your test goes here }}

Cucumber-jvm

8

Expression régulière

public class RecipeStepdefs { @Given("^\"([^\"]*)\" is flying an X-wing$") public void userIsFlyingAnXwing(String user) throws Throwable { // Your test goes here }

public class RecipeStepdefs { @Given("^\"([^\"]*)\" is flying an X-wing$") public void userIsFlyingAnXwing(String user) throws Throwable { // Your test goes here } @When("^He drops his torpedoes$") public void heDropsHisTorpedeos() throws Throwable { // Your test goes here } @Then(« ^The death star should be destroyed$") public void theDeathStarShouldBeDestroyed() throws Throwable { // Your test goes here }}

Cucumber-jvm

8

Expression régulière

Given "Luke" is flying an X-wing

Cucumber-jvm - Java 8

9

public class RecipeJava8Stepdefs implements En { public RecipeJava8Stepdefs() { Given("^\"([^\"]*)\" is flying an X-wing$", () -> { // Your test goes here }); When("^He drops his torpedoes$", () -> { // Your test goes here }); Then(« ^The death star should be destroyed$", () -> { // Your test goes here }); }}

i18n ?

raaaaaahhgh uughghhhgh aaaaahnr

uughghhhgh awwgggghhh wuuh*

*Je ne comprends pas ce que tu dis

# language: fr

11

# language: frFonctionnalité: Faire une course de racer En tant que pilote Je souhaite participer à une course Afin de gagnerScénario: Je participer à une course Etant donné que "Luke" a un module de course Lorsqu’il participe à la course Alors il gagne

implémentation

12

@Etantdonné("^que \"([^\"]*)\" a un module de course$") public void queAUnModuleDeCourse(String personnage) throws Throwable { // TODO } @Lorsqu("^il participe à la course$") public void ilParticipeALaCourse() throws Throwable { // TODO} @Alors("^il gagne$") public void ilGagne() throws Throwable { // TODO}

Teach me the force

Mais le BDD, ça fonctionne vraiment ?

Pour aller plus loin…

Référenceshttp://dannorth.net/introducing-bdd/ http://blog.viseo-bt.com/as-viseo-we-went-to-cukeup-so-we-can-improve-our-bdd/ https://cucumber.io https://github.com/sichida/BDD-examples/tree/jug_toulouse https://github.com/cucumber/cucumber/wiki/Spoken-languages http://fr.slideshare.net/ichidashoun/

Avez-vous des questions

?