May the feature be with you

20
May The Feature Be With You #bdd [email protected] Shoun ICHIDA @ishoun #JUGToulouse

Transcript of May the feature be with you

Page 1: May the feature be with you

May The Feature Be With You

#bdd

[email protected] ICHIDA

@ishoun

#JUGToulouse

Page 2: May the feature be with you

Behavior Driven Development? ?

?

??

?

Page 3: May the feature be with you

qu’est-ce que c’est ?

➡ Une méthodologie de développement

3

Page 4: May the feature be with you

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

Page 5: May the feature be with you

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

5

TEST QUI RÉUSSITTESTQUI ÉCHOUE

Refactoring

TDDTest

d’Acceptation

qu’apporte-t-elle ?

Page 6: May the feature be with you

Solutions

Page 7: May the feature be with you

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

Page 8: May the feature be with you

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

Page 9: May the feature be with you

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

Page 10: May the feature be with you

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

Page 11: May the feature be with you

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

Page 12: May the feature be with you

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

Page 13: May the feature be with you

i18n ?

raaaaaahhgh uughghhhgh aaaaahnr

uughghhhgh awwgggghhh wuuh*

*Je ne comprends pas ce que tu dis

Page 14: May the feature be with you

# 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

Page 15: May the feature be with you

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}

Page 16: May the feature be with you

Teach me the force

Page 17: May the feature be with you

Mais le BDD, ça fonctionne vraiment ?

Page 18: May the feature be with you

Pour aller plus loin…

Page 19: May the feature be with you

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/

Page 20: May the feature be with you

Avez-vous des questions

?