bdd - beyond: given, when and then

25
Behaviour Driven Development Beyond “Given, When, Then” Antony Marcano

Upload: riverglide

Post on 13-Jan-2015

1.495 views

Category:

Technology


3 download

DESCRIPTION

Behaviour Driven Development (BDD) is an evolution of test-driven development that places explicit emphasis on language, communication and 'outside-in' development. Many people are familiar with the 'Given,When,Then' structure used in BDD specifications (or acceptance tests) but is that really where it ends? In this session Antony Marcano gives a short intro to BDD, explains 'outside-in' development. Using a metaphor from learning theory and HCI principles, he'll show you how to go beyond 'Given,When,Then' to a shared understanding of your customer's needs.

TRANSCRIPT

Page 1: BDD - beyond: Given, When and Then

Behaviour Driven DevelopmentBeyond “Given, When, Then”

Antony Marcano

Page 2: BDD - beyond: Given, When and Then

The Telephone Game

http://www.brokenpicturetelephone.com/

Page 3: BDD - beyond: Given, When and Then

What is BDD?

Beyond “Given, When, Then”

Page 4: BDD - beyond: Given, When and Then

BDD Origins

‘The deeper I got into TDD, the more I felt that my own journey had been less of a wax-on, wax-off process of gradual mastery than a series of blind alleys. I remember thinking “If only someone had told me that!”… I decided it must be possible to present TDD in a way that gets straight to the good stuff and avoids all the pitfalls. My response is behaviour-driven development (BDD). Over time, BDD has grown to encompass the wider picture of agile analysis and automated acceptance testing.’-Dan North

Page 5: BDD - beyond: Given, When and Then

BDD Origins - Shortened

“ Behaviour Driven Development (BDD) builds upon Test-Driven Development (TDD) by formalising the good habits of the best TDD practitioners. ” – The Cucumber Book, Aslak Hellesøy, Matt Wynne

Page 6: BDD - beyond: Given, When and Then

Some ‘Good Habits’

Slice VerticallyWork from the outside-in

One example at a time

Page 7: BDD - beyond: Given, When and Then

Slice Vertically

Page 8: BDD - beyond: Given, When and Then

2009 8

Traditionally, development is sliced horizontallySo

ftw

are

Com

pone

nts

(mod

ules

/cla

sses

)

Use

r Sto

ry A

Use

r Sto

ry B

Use

r Sto

ry C

Use

r Sto

ry D

Sprint n Sprint n+1… Sprint x

time

Soft

war

e Co

mpo

nent

s(m

odul

es/c

lass

es)

Logi

n

Crea

te a

lbum

Shar

e ph

otos

Priv

ate

albu

ms

Iteration n Iteration n+1… Iteration x

time

…but defers feedback (often, until it’s too late)

Page 9: BDD - beyond: Given, When and Then

2009 9

Soft

war

e Co

mpo

nent

s(m

odul

es/c

lass

es)

Shar

e ph

otos

Crea

te a

lbum

Shar

e ph

otos

Logi

n

Crea

te a

lbum

Shar

e ph

otos

Priv

ate

albu

ms

Iteration n Iteration n+1 Iteration x

time

Vertical slicing

…results in earlier feedback

Page 10: BDD - beyond: Given, When and Then

Work from the outside-in

Page 11: BDD - beyond: Given, When and Then

Outside-in

Page 12: BDD - beyond: Given, When and Then

One example at a time

Page 13: BDD - beyond: Given, When and Then

One example at a time

Page 14: BDD - beyond: Given, When and Then

Elaborate as anautomated scenario (aka acceptance test)

Implement story driving with unit tests Scenario should pass

When all Scenarios pass, story is done(almost)

For each Example illustrating the story

Have a conversation

One example at a time

Test should fail

Page 15: BDD - beyond: Given, When and Then

Expressing Examples

Given, When, ThenAnd beyond

Page 16: BDD - beyond: Given, When and Then

Given When Then

Given <some initial context>When <something happens>Then <some expectation>

Page 17: BDD - beyond: Given, When and Then

Given When Then

Given <some initial context>[and some additional context]

When <something happens>[and something else happens]

Then <some expectation>[and some more expectations]

Page 18: BDD - beyond: Given, When and Then

A Typical Illustration

Scenario: Login SuccessfullyGiven I am on the home-pageWhen I enter the username ‘antony’And I enter the password ‘p4$$w0rd’And I click ‘login’

Then I should be logged in

What’s wrong with this example?

Page 19: BDD - beyond: Given, When and Then

A Better Illustration

Scenario: Login SuccessfullyWhen I login as ‘antony’ with the password ‘p4$$w0rd’Then I should be logged in

Why is it better?

Page 20: BDD - beyond: Given, When and Then

Task Analysis

A little UX for our BDD

Page 21: BDD - beyond: Given, When and Then

• Pitching it right…– Goals e.g. Withdraw Cash

• Tasks Identify to bank Request amount

– (inter)actionsInsert Card

Enter PinPress “Withdraw Cash”

Enter amountPress OK

} Just right

} Too low level

Page 22: BDD - beyond: Given, When and Then

For example…

When I add, the number ‘2’ and the number ’3’

http://cukesalad.info

actions}

task

Page 23: BDD - beyond: Given, When and Then

Some nice side-effects

Encourages description of UI interactions in one place

Makes it easier to execute scenariosvia different interfaces

Page 24: BDD - beyond: Given, When and Then

Discussion

Questions?Ideas?

Feedback?

Page 25: BDD - beyond: Given, When and Then

[email protected] @[email protected]

@RiverGlide/rs

http://twitter.com/RiverGlide/rs

http://cukesalad.info #cukesaladhttp://RiverGlide.com @RiverGlide