You are on page 1of 20

BEHAVIOR DRIVEN

DEVELOPMENT (BDD)
João Ferreira

2021

C MPASS
I´m glad we all agree

1
Agile … is aging

2
Meet Dan & Liz

Dan North Liz Keogh

“Communication and collaboration framework for developers, QA and non-technical or


business participants in a software project” 2009

“It's using examples to talk through how an application behaves... And having
conversations about those examples.” 2013

BDD is a means of clearing confusion between testers,


developers, and business people.
3
Deliberate Discovery

BDD is a means of clearing confusion between


testers, developers, and business people.

• Business – What problem are we trying to solve?


• Development – How might we build a solution to solve that problem?
• Testing – What about this, what could possibly happen?

4
Shift Left Model

5
User Stories have three critical aspects

“Card”
The card has just enough text to identify the requirement, and to remind everyone what the story is.
(As … I want … so that …)

“Conversation”
The requirement itself is communicated from customer to developers through conversation:
an exchange of thoughts, opinions, and feelings.

“Confirmation”
When the conversation about a card gets down to the details of the acceptance test,
the customer and developers settle the final details of what needs to be done.

6
Source: Ron Jeffries; Essential XP: Card, Conversation, Confirmation
Highlighting the impact

7
Extracting information via conversations

conversations

conversations

conversations

8
Formalized Acceptance Criteria

Title (one line describing the story)

Narrative:
In order to [impact]
a [role]
Wants [feature]

Acceptance Criteria: (presented as Scenarios)

confirmation Scenario 1: Title


Given [context]
And [some more context]...
When [event]
Then [outcome]
And [another outcome]...

Scenario 2: ...

9
User Story practice is not linear

10
Exercise

11
11
Example: Narrative

Story: Account Holder withdraws cash

In order to request money when the bank is closed


As an Account Holder
I want to withdraw cash from an ATM

12
Example: scenario 1

Story: Account Holder withdraws cash

In order to request money when the bank is closed


As an Account Holder
I want to withdraw cash from an ATM

Scenario 1: Account has sufficient funds


Given the account balance is €100
When I withdraw €20 from an ATM with card
Then the ATM should dispense €20
And the card should be returned
And the account balance should be €80

13
Example: scenario 2 Story: Account Holder withdraws cash

In order to request money when the bank is closed


As an Account Holder
I want to withdraw cash from an ATM

Scenario 1: Account has sufficient funds


Given the account balance is €100
When I withdraw €20 from an ATM with card
Then the ATM should dispense €20
And the card should be returned
And the account balance should be €80

Scenario 2: Account has insufficient funds


Given the account balance is €10
When I withdraw €20 from an ATM with card
Then the ATM should not dispense any money
And the card should be returned
And the account balance should be €10
And the ATM should say there are insufficient funds

14
Story: Account Holder withdraws cash
Example: scenario 3
In order to request money when the bank is closed
As an Account Holder
I want to withdraw cash from an ATM

Scenario 1: Account has sufficient funds


Given the account balance is €100
And the card is valid
When I withdraw €20 from an ATM with card
Then the ATM should dispense €20
And the card should be returned
And the account balance should be €80

Scenario 2: Account has insufficient funds


Given the account balance is €10
And the card is valid
When I withdraw €20 from an ATM with card
Then the ATM should not dispense any money
And the card should be returned
And the account balance should be €10
And the ATM should say there are insufficient funds

Scenario 3: Card has been disabled


Given the account balance is €100
And the card is disabled
When I withdraw €20 from an ATM with card
Then the ATM should say the card has been retained
And the account balance should be €80
And the card should not be returned

15
Story: Account Holder withdraws cash

In order to request money when the bank is closed


Example: scenario 4 As an Account Holder
I want to withdraw cash from an ATM

Scenario 1: Account has sufficient funds


Given the account balance is €100
And the card is valid
And the ATM contains enough money
When I withdraw €20 from an ATM with card
Then the ATM should dispense €20
And the card should be returned
And the account balance should be €80

Scenario 2: Account has insufficient funds


Given the account balance is €10
And the card is valid
And the ATM contains enough money
When I withdraw €20 from an ATM with card
Then the ATM should not dispense any money
And the card should be returned
And the account balance should be €10
And the ATM should say there are insufficient funds

Scenario 3: Card has been disabled


Given the account balance is €100
And the card is disabled
When I withdraw €20 from an ATM with card
Then the ATM should say the card has been retained
And the account balance should be €80
And the card should not be returned

Scenario 4: The ATM has insufficient funds


Given the account balance is €100
And the card is valid
And the ATM does not contain enough money
When I withdraw €20 from an ATM with card
Then the ATM should not dispense any money
And the card should be returned
And the account balance should be €100
And the ATM should say it is out of cash 16
Slicing a story becomes easy

17
Regression testing grows fast with each change

18

You might also like