behavior driven development

Post on 12-Nov-2014

20.661 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Annotated slides from my "Behavior Driven Development" course. Released under Creative Commons share-alike, commercial and derivatives allowed: http://creativecommons.org/licenses/by-sa/3.0/

TRANSCRIPT

BehaviourDrivenDevelopment

Liz Keogh@lunivore

Behaviour-Driven Development

Feature Injection

Cynefin and Differentiation

Splitting Stories

BDDuses examples

to illustrate behavior

An Example of an Example

Given Fred has bought a microwaveAnd the microwave cost £100

When we refund the microwaveThen Fred should be refunded £100.

An Example of an Example

Given baby rabbits cost £10When we sell Snowy the Baby RabbitThen the customer should be charged

£10.

Examples

Given a contextWhen an event happens

Then an outcome should occur

“Given Scenario” – an antipattern

Given Fred puts a microwave in the basketAnd the microwave cost £100

When Fred buys the microwaveThen he should be charged £100When we refund the microwave

Then Fred should be refunded £100.

Cucumber

Feature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen

This is what most peopleassociate with BDD

BDD is about having conversations

BDD should make it easyto create software

A scenario is an idea, not a promise

A scenario is an idea, not a promise

Having conversations

is more important thancapturing conversations

is more important thanautomating conversations

Exercise

Think of thebest conversations

you’ve had.What made them awesome?

Entertaining

Learning

Questions

ChallengeDifferentopinions

Uncertainty

Shared context

Newpeople

IdeasSupportCertainty

A storybecause devs love

empty lists

Boring!

Given Fred bought a microwaveAnd has receipt number 1857123

And receipt 1857123 lists it at £100When we scan the receipt

Then the screen should show the list of itemsWhen we select the microwave

And we refund itAnd scan Fred’s credit card

Then Fred should be refunded £100.

Examples

Given a contextWhen an event happens

Then an outcome should occur

Should it?

Make sure you get it right

Assume you got it wrong

Is there a context in whichthis event will createa different outcome?

Examples

Given Fred has bought a microwaveAnd the microwave cost £100

And the microwave was on 10% discountWhen we refund the microwave

Then Fred should be refunded £90.

Examples

Given Fluffy the baby rabbitis 1 ½ months old

When we try to sell FluffyThen we should be told he’s too young

Is this the only outcomethat matters?

If we could achieve it with pixies, would it be enough?

Examples

Given Fred has bought a microwaveAnd the microwave cost £100

When we refund the microwaveThen the microwave should be

added to the stock count.

Examples

Given each rabbit eats an average of20g of carrots a day

When we sell 10 rabbitsAnd 5 rabbits are born

Then our order for carrots shouldgo down by 700g a week

Same scenario?

Then Fred should be refunded £100

Then the microwave should be addedto the stock count

Same scenario?

Then I should be given £20

And £20 should be debitedfrom my account

Then my eyes glaze over…

When we select “baby rabbit” from the list of petsAnd the customer declines all special offersAnd we want a VAT receiptAnd we select payment by credit cardAnd the customer is presentThen the receipt should say £10And we should have £10 more takingsAnd the number of rabbits in stock should decreaseAnd …

Then my eyes glaze over more

When we click the “Pets” drop-downAnd we select “baby rabbits”And we click “No”And we check “VAT receipt”And we click “Pay”And we select “Credit Card”And we click “Yes”And …

Exercise

Come up with two scenarios

withtwo outcomes

from your own work,one of which can be splitand one of which can’t.

(They don’t have to be about software)

And you can keep going…

Given Fred has bought a microwaveAnd the microwave cost £100And the microwave is faulty

When we refund the microwaveThen a fault ticket should be printed.

Exercise

What other benefitscan you think of

that might come fromtalking through

different scenarios?

Acceptance criteria vs. Scenarios

Given Fred has bought a microwaveAnd the microwave cost £100

And the microwave was on 10% discountWhen we refund the microwave

Then Fred should be refunded £90.

Acceptance criteria vs. Scenarios

Given an item was soldwith a discount

When a customer gets a refundThen he should only be refunded

the discounted price.

Acceptance criteria vs. Scenarios

Items should be refundedat the price at which they were sold.

Acceptance criteria vs. Scenarios

Given Fluffy the baby rabbitis 1 ½ months old

When we try to sellFluffy the baby rabbit

Then we should be toldthat he’s too young

Acceptance criteria vs. Scenarios

Given a pet is belowrecommended selling age

When we try to sellthat pet

Then we should be toldthat the pet is too young

Acceptance criteria vs. Scenarios

We shouldn’t be ableto sell pets

younger than therecommended

selling age

Exercise

Can you derive some scenariosfrom these acceptance criteria?

The user should be able to add and remove bold, italics and underlines.

When browsing an item, users should be able to see what other users who browsed the item bought.

Pets shouldn’t be listed for saleuntil they’re old enough.

Feature Injection

Vision

Makes moneySaves money

Protects money

PrimaryStake-holder

Goal

Neededto go liveIncidental

Stake-holder

Capability

Userscan achievea businessoutcome

Business Analyst

Feature

User interfacecomponent

which enablesa capability

UIDesigner

Story

A slice througha featureto enable

faster feedback

Often adeveloper

Scenario

An exampleof how the system

might behavefrom a userperspective

Dev, tester,analyst

Code

Ideas turning intorealityDeveloper

Visi

on

Goa

l

Capa

bilit

y

Feat

ure

Stor

y

Scen

ario

Code

Visi

on

Goa

l

Capa

bilit

y

Feat

ure

Stor

y

Scen

ario

Code

Visi

on

Goa

l

Capa

bilit

y

Feat

ure

Stor

y

Scen

ario

Code

Exercise

Who are your stakeholders?

Examples can help youdiscover

things early

Is there a stakeholder for whomthis application will not meet their goal?

Are all of the stakeholder’s goalsmet by this?

If we could achieve it with pixies, would it be enough?

Traditional

Rework

Developers Testers

Deliberate Discovery skills

BDD

Less Rework

Developers Testers

Deliberate Discovery skills

Testers

1 2 4 5

1 2 3 4 5

1 2 ? 4 5

1 2 : 4 5

Real Options

Options have value.

Options expire.

Never commit earlyunless you know why.

Business Analyst

DeveloperTester

Cynefin and Differentiation

Kuh-nev-vin

The Big Bucket

A Gantt Chart…

1 1 1

3 32 2

1

23

1

1

1

3

3

2

2

…on its side

Backlog1

1

1

3

3

2

2

If a project has no risks,

don’t do it.

Prioritizing for deadline

$$$$$$$$

$$$$$$$$

$$$$$$$$

$$$$$

$$$$$

$$

$$

$$

Shipped (1 year)

Not ShippedDeadline

Minimum Viable Product

$$$$$$$$

$$$$$$$$

$$$$$$$$

$$$$$

$$$$$

$$

$$

$$

Shipped (2 months)

Not Shipped

Not Shipped

Shipped (2 months)

Types of Software

DifferentiatorsCommodities

KatasExpedite

Types of SoftwareSpoilers

Cynefin

Simple

ComplicatedComplex

Chaotic

With thanks toDavid Snowden and Cognitive Edge

Cynefin

With thanks toDavid Snowden and Cognitive Edge

Disorder

Cynefin

Simple

Chaotic

With thanks toDavid Snowden and Cognitive Edge

Cynefin

Breaking thingsdown

Cynefin

Tryingthings

out

BDD works really well……hereish.

Exercise

Help mestop the spammers!

Fractal beauty

Vision

Goal

Goal

Goal

Capability

Capability

Feature

Feature

Feature

Story

Story

Story

Scenario

Scenario

Code

Code

Code

GoalScenario

Goal

Feature

A Real Project

VisionGoal

Capability

Capability

Feature

Feature

Story

Story

Story

Scenario

Code

Code

Code

Whoops,forgot

Oops, didn’t know about

that…Look what I

found!

Don’t need this… Can’t

remember what this was for…

GoalScenario

Goal

Feature

A Real Project

VisionGoal

Capability

Capability

Feature

Feature

Story

Story

Story

Scenario

Code

Code

Code

Whoops,forgot

Oops, didn’t know about

that…Look what I

found!

Don’t need this… Can’t

remember what this was for…

Um

Er…

Oh!

Oh F… Dammit!

Hmm!

That’s funny!

Ooh, look!

Interesting! Sh..!Oops!

We’re uncovering better ways ofdeveloping software by doing it

Vision

Goal

Goal

Goal

Capability

Capability

Feature

Feature

Feature

Story

Story

Story

Scenario

Scenario

Code

Code

Code

We’re discovering how to discover stuff by doing it

Whoops,forgot

Oops, didn’t know about

that…Look what I

found!

Don’t need this…

Can’t remember what this was for…

Um…

Er…

Oh!

Oh F… Dammit!

Hmm!

That’s funny!

Ooh, look!

Interesting!

Sh..!Oops!

Different levels of granularity

Make assmall a commitment

as possiblethen get feedback

Risk (Newest Stuff) First

Vision

Goal

Goal

Goal

Capability

Capability

Feature

Feature

Feature

Story

Story

Story

Scenario

Scenario

Code

Code

Code

Feature

Goal

Capability

ScenarioCode

Story

High-level, risk-first

Sometimes you discoverthat you

don’t know

High-level, risk-first

Exercise

What should your boardlook like now?

Boring!

Given Fred has bought a microwaveAnd the microwave cost £100

When we refund the microwaveThen Fred should be refunded £100.

Interesting!

Given Fred has bought a 120kg fridge-freezer

When we refund the fridge-freezerThen um…

Exercise

Can you derive a more interesting scenariofrom these acceptance criteria?

The user should be able to add and remove bold, italics and underlines.

When browsing an item, users should be able to see what other users who browsed the item bought.

Pets shouldn’t be listed for saleuntil they’re old enough.

Find the examplesyou

can’t find.

If you’ve done it before,you have

expectations.If you’ve never done it,

all you have arehopes.

Splitting featuresinto stories

Fred Buyer999 Letsby AvenueLondonN1 0UC

By Spiking

Fred

Buyer

Save

New

Stabilizing

Walking Skeleton

Walking Skeleton

By Input

By Output

By Behaviour

Expand

With thanks toMichael James

Don’t let your processhide yourignorance.

Theory of Constraints:A Thought Experiment

This is what I learnt

yesterday.

This is what I hope tofind outtoday.

Having conversations

is more important thancapturing conversations

is more important thanautomating conversations

Liz Keoghhttp://lizkeogh.com@lunivore

top related