+ All Categories
Transcript
Page 1: L'ABC du BDD (Behavior Driven Development)

BA CL’BDDCE QUE C’est

OU Ce QUE C’est pas…

Arnauld Loyer @aloyer

2014

du

Page 2: L'ABC du BDD (Behavior Driven Development)

http://pencilink.blogspot.fr/2010/10/iron-man-160-jim-starlin-cover-steve.html

It’s NOT about tools

It’s about Communication and Behavior!

@aloyer

Page 3: L'ABC du BDD (Behavior Driven Development)

http://ungoliantschilde.tumblr.com/post/78793890826/ungoliantschilde-barry-windsor-smith-that

It’s NOT about Testing

It’s about Exploring the Unknown

@aloyer

Page 4: L'ABC du BDD (Behavior Driven Development)

It’s not about Silo!Or Acceptance

Criteria

It’s about Sharing

and Understanding

@aloyer

Page 5: L'ABC du BDD (Behavior Driven Development)

It’s about Driven Development!

@aloyer

Page 6: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

Modèle Mental

@aloyer

@aloyer

@aloyer

Page 7: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

Modèle Mental

Ce qui est expliqué

Ce qui n'est pas

retranscrit Modèle Mental

@aloyer

@aloyer

@aloyer

Page 8: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

Modèle Mental

Ce qui est expliqué

Ce qui n'est pas

retranscrit Modèle Mental

Ce que l'autre comprend

@aloyer

@aloyer

@aloyer

Page 9: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

Ce qui est spécifié

@aloyer

@aloyer

@aloyer

Page 10: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

Ce qui va être testé

@aloyer

@aloyer

@aloyer

@aloyer

Page 11: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

Ce qui va être testé

Ce qui est réalisé@

aloyer

@aloyer

@aloyer

@aloyer

Page 12: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

@aloyer

@aloyer

@aloyer

Page 13: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

@aloyer

@aloyer

@aloyer

Page 14: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

Correspond à l'idée initiale

Ce qui a été réalisé

@aloyer

@aloyer

Page 15: L'ABC du BDD (Behavior Driven Development)

Qu'est ce qui se passe?

Correspond à l'idée initiale

Ce qui a été réaliséNNNAaannnnnn

vs

@aloyer

@aloyer

Page 16: L'ABC du BDD (Behavior Driven Development)

"is this a bug or is this not a bug”

a bug?

a feature?

an enhancement?

a beature?

@aloyer

Page 17: L'ABC du BDD (Behavior Driven Development)

@aloyer

Page 18: L'ABC du BDD (Behavior Driven Development)

@aloyer

Page 19: L'ABC du BDD (Behavior Driven Development)

@aloyer

Page 20: L'ABC du BDD (Behavior Driven Development)

3 steps 3 model

3 interpretations

@aloyer

Page 21: L'ABC du BDD (Behavior Driven Development)

3 visions 1 model 1 goal

@aloyer

Page 22: L'ABC du BDD (Behavior Driven Development)

Three Amigos @aloyer

Page 23: L'ABC du BDD (Behavior Driven Development)

http://paintings-art-picture.com/paintings/archives/85/marvel-comics-retro-captain-america-comic-panel-fighting-phase-1-so-far-so-good-aged

BDD is writing software that matters

@aloyer

Page 24: L'ABC du BDD (Behavior Driven Development)

@aloyer

@aloyer

Page 25: L'ABC du BDD (Behavior Driven Development)

BDD is about conversation

@aloyer

@aloyer

Page 26: L'ABC du BDD (Behavior Driven Development)

@aloyer

Page 27: L'ABC du BDD (Behavior Driven Development)

@aloyer

Page 28: L'ABC du BDD (Behavior Driven Development)

Why?

Goal?Business Value?

Intention What?

How!

@aloyer

@aloyer

Page 29: L'ABC du BDD (Behavior Driven Development)

Why?

Goal?Business Value?

In order to <achieve the vision>

Feature: ...

As a <stakeholder>I want <value>

Intention

As a <role>I want <goal>So that <value>

User focused

What?

How!

@aloyer

@aloyer

Page 30: L'ABC du BDD (Behavior Driven Development)

No Narrative No Business Value

Unnecessary Feature !

@aloyer

Page 31: L'ABC du BDD (Behavior Driven Development)

22

http://devjam.com/2010/08/05/dudes-law-gordon-pask-shoveler/

Page 32: L'ABC du BDD (Behavior Driven Development)

In order to...Feature: ...

As a...I want to...Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

BDD uses examples to illustrate behavior@aloyer

@aloyer

Page 33: L'ABC du BDD (Behavior Driven Development)

Why do YOU like should?

It encourages debate, and

constant Questioning

of the premise of the application you are

developing.

Dan North, March 2005

@aloyer

Page 34: L'ABC du BDD (Behavior Driven Development)

Feature: Account Holder withdraws cash from an ATM ! In the following scenario, ATM will stands for Automatic Teller Machine in other word a “Cash machine”. ! In order to get money at any time, even when the bank is closed As an Account Holder I want to withdraw cash from an ATM !Scenario: Account has sufficient funds Given the account balance is 100€ When the Account Holder requests 20€ Then the ATM should dispense 20€ And the account balance should be 80€ And the card should be returned

@aloyer

Page 35: L'ABC du BDD (Behavior Driven Development)

Scenario: Account has insufficient funds Given the account balance is 10€ And the card is valid And the machine contains enough money When the Account Holder requests 30€ Then the ATM should not dispense any money And the ATM should say there are insufficient funds And the account balance should still be 10€ And the card should be returned

@aloyer

Page 36: L'ABC du BDD (Behavior Driven Development)

Scenario: Account has insufficient funds Given the account balance is 10€ And the card is valid And the machine contains enough money When the Account Holder requests 30€ Then the ATM should not dispense any money And the ATM should say there are insufficient funds And the account balance should still be 10€ And the card should be returned

FOCUS On the BEHAVIOR DESCRIBED!

@aloyer

Page 37: L'ABC du BDD (Behavior Driven Development)

@aloyer

Page 38: L'ABC du BDD (Behavior Driven Development)

Feature: Interpolate !

In order to interpolate values As an Trader I want to interpolate values in a range of Market

data

Why this feature ?

@aloyer

Page 39: L'ABC du BDD (Behavior Driven Development)

Feature: Linear Interpolation In order to fill the gaps and provide a value for any

maturity As a trader responsible for market-making I want to interpolate linearly values within a range of

points And I want a flat extrapolation outside of the range

of points

Why this feature ?

@aloyer

Page 40: L'ABC du BDD (Behavior Driven Development)

Scenario: Change the negotiation price from positive to negative => soulte cashflow appears and premium cashflow is modified

!Given an FUNKY_EXOTIC And deal way is sell And deal nature is TOMATO And trade value date is 2012/07/01 And nominal is 100 JPY And negotiation price is 0.20 JPY When I validate the deal Then there are 1 Price cashflows And there are 0 fee cashflows When I change the negotiation price to -0.3 JPY And I validate the deal Then there are 1 Price cashflows And there are 1 fee cashflows And the trade cashflow's payment date is 2012/07/01 And the trade cashflow's way is receive And the trade cashflow's amount is 30 JPY And the fee cashflow's payment date is 2012/07/01 And the fee cashflow's way is give And the fee cashflow's amount is 60 JPY

What about this scenario

@aloyer

Page 41: L'ABC du BDD (Behavior Driven Development)

What about this scenario

d = new Deal(); d.SetWay(Sell); d.SetNature(Tomato); d.SetValueDate(new Date(...)); d.SetNominal(100, JPY); d.SetNegotiationPrice(0.20, JPY); cf = d.GetCashFlows(); AssertThat(IsEqual(...); ...

Scenario: Change the negotiation price from positive to negative => soulte cashflow appears and premium cashflow is modified

!Given an FUNKY_EXOTIC And deal way is sell And deal nature is TOMATO And trade value date is 2012/07/01 And nominal is 100 JPY And negotiation price is 0.20 JPY When I validate the deal Then there are 1 Price cashflows And there are 0 fee cashflows When I change the negotiation price to -0.3 JPY And I validate the deal Then there are 1 Price cashflows And there are 1 fee cashflows And the trade cashflow's payment date is 2012/07/01 And the trade cashflow's way is receive And the trade cashflow's amount is 30 JPY And the fee cashflow's payment date is 2012/07/01 And the fee cashflow's way is give And the fee cashflow's amount is 60 JPY

@aloyer

Page 42: L'ABC du BDD (Behavior Driven Development)

SCEnARIO: Fee and Price cashflows when the negotiation price is set to a negative value

!Given a sell for a nominal 100 JPY on FUNKY_EXOTIC TOMATO

negotiation price 0.20 JPY traded on 2012/07/01 When the middle officer validates the deal Then the trade has one Price cashflow and no Fee cashflow When the middle officer changes the negotiation price to -0.3 JPY And the middle officer validates the deal Then the trade has the following cashflows:

What about this scenario

Communicate With the Business People !!!

FlowType

Price Fee

Way

Receive Give

Amount

30 60

Currency

JPY JPY

Payment Date

2012/07/01 2012/07/01

Remarks

100*abs(-0.3) 100*2*abs(-0.3)

@aloyer

Page 43: L'ABC du BDD (Behavior Driven Development)

Low Tech

Scenario

@aloyer

@aloyer

Page 44: L'ABC du BDD (Behavior Driven Development)

@aloyer

@aloyer

Page 45: L'ABC du BDD (Behavior Driven Development)

@aloyer

Domain Driven Design - Eric Evans @aloyer

Page 46: L'ABC du BDD (Behavior Driven Development)

In order to...Feature: ...

As a...I want to...

Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

Examples help discover things early@aloyer

@aloyer

Page 47: L'ABC du BDD (Behavior Driven Development)

In order to...Feature: ...

As a...I want to...

Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

One may discover that one doesn't know

but others do!

@aloyer

@aloyer

Page 48: L'ABC du BDD (Behavior Driven Development)

WHAT About Automation !?!

The Green

Thing

?

@aloyer

Page 49: L'ABC du BDD (Behavior Driven Development)

GLUE

COD

E

BDD

FRAM

EWOR

K

SCEN

ARIO

APPL

ICAT

ION

"End to End"

UI FEST, Selenium, Fluentlenium,

HtmlUnit, Watir...

@aloyer

Page 50: L'ABC du BDD (Behavior Driven Development)

GLUE

COD

E

BDD

FRAM

EWOR

K

SCEN

ARIO

APPL

ICAT

ION

"End to End"

Services

Web, WCF, ...

@aloyer

Page 51: L'ABC du BDD (Behavior Driven Development)

GLUE

COD

E

BDD

FRAM

EWOR

K

SCEN

ARIO

APPL

ICAT

ION

Sub-Moduleruntime

@aloyer

Page 52: L'ABC du BDD (Behavior Driven Development)

GLUE

COD

E

BDD

FRAM

EWOR

K

SCEN

ARIO

APPL

ICAT

ION

"Quasi-Unitaire"runtime

@aloyer

Page 53: L'ABC du BDD (Behavior Driven Development)

GLUE

COD

E

BDD

FRAM

EWOR

K

SCEN

ARIO

APPL

ICAT

ION

"Quasi-Unitaire"runtime

Mock, Stubs...

@aloyer

Page 54: L'ABC du BDD (Behavior Driven Development)

GLUE

COD

E

BDD

FRAM

EWOR

K

SCEN

ARIO

APPL

ICAT

ION

@aloyer

Page 55: L'ABC du BDD (Behavior Driven Development)

Scenario: Account has sufficient funds! Given the account balance is 100€! When the Account Holder requests 20€ Then the ATM should dispense 20€! And the account balance should be 80€! And the card should be returned

SCENARIO

GLUE

COD

E

BDD

FRAM

EWOR

K

APPL

ICAT

ION

@aloyer

Page 56: L'ABC du BDD (Behavior Driven Development)

Scenario: Account has sufficient funds! Given the account balance is 100€! When the Account Holder requests 20€ Then the ATM should dispense 20€! And the account balance should be 80€! And the card should be returned

SCENARIO

GLUE

COD

E

BDD

FRAM

EWOR

K

APPL

ICAT

ION

@aloyer

Page 57: L'ABC du BDD (Behavior Driven Development)

Scenario: Account has sufficient funds! Given the account balance is 100€! When the Account Holder requests 20€ Then the ATM should dispense 20€! And the account balance should be 80€! And the card should be returned

SCENARIO

@Given("^the account balance is (\d+)€$") public void defineAccountBalanceInEuro(BigDecimal balance) { throw new PendingException("Implements me!"); } !@When("^the Account Holder request (\d+)€$") public void withdrawInEuro (BigDecimal amount) { throw new PendingException("Implements me!"); } !@Then("^the ATM should dispense (\d+)€$") public void assertMoneyDispensedInEuro (BigDecimal amount) { throw new PendingException("Implements me!"); } !!!@Then("^the account balance should be (\d+)€$") public void assertBalanceInEuro(BigDecimal amount) { throw new PendingException("Implements me!"); } !

GLUE CODE

APPL

ICAT

ION

BDD

FRAM

EWOR

K

@aloyer

Page 58: L'ABC du BDD (Behavior Driven Development)

Scenario: Account has sufficient funds! Given the account balance is 100€! When the Account Holder requests 20€ Then the ATM should dispense 20€! And the account balance should be 80€! And the card should be returned

SCENARIO

@Given("^the account balance is (\d+)€$") public void defineAccountBalanceInEuro(BigDecimal balance) { account().setBalance(euro(balance)); } !@When("^the Account Holder request (\d+)€$") public void withdrawInEuro (BigDecimal amount) { atm().withdraw(account(), euro(amount)); } !@Then("^the ATM should dispense (\d+)€$") public void assertMoneyDispensedInEuro (BigDecimal amount) { TransactionLog txLog = atm().transactionLog();! Money dispensed = txLog.lastAmountDispensed();! assertThat(dispensed).isEqualTo(euro(amount)); }!!@Then("^the account balance should be (\d+)€$") public void assertBalanceInEuro(BigDecimal amount) { Money actualBalance = account().balance();! assertThat(actualBalance).isEqualTo(euro(amount)); }

GLUE CODE

APPL

ICAT

ION

BDD

FRAM

EWOR

K

@aloyer

Page 59: L'ABC du BDD (Behavior Driven Development)

And that’s all Folks… for the Green Thing!

but remember, you can

automate from unit level to end-to-end

level

@aloyer

Page 60: L'ABC du BDD (Behavior Driven Development)

THE PointIf only one thing must remain

@aloyer

Page 61: L'ABC du BDD (Behavior Driven Development)

BDD = Shared understanding by discussing Examples

@aloyer

Page 62: L'ABC du BDD (Behavior Driven Development)

BDD = Shared understanding by discussing Examples

Three AmiGOS

@aloyer

Page 63: L'ABC du BDD (Behavior Driven Development)

BDD = Shared understanding by discussing Examples

Scenario

Three AmiGOS

@aloyer

@aloyer

Page 64: L'ABC du BDD (Behavior Driven Development)

Questions?

http://rozmaryn.deviantart.com/art/Hellboy-bw-52117973

@aloyer


Top Related