Pitt agile201505

70
Don’t start with login! BDD for collaboration and testing Nate Peterson @njpetersonpa

Transcript of Pitt agile201505

Page 1: Pitt agile201505

Don’t start with login!

BDD for collaboration and testing

Nate Peterson@njpetersonpa

Page 2: Pitt agile201505

- BDD overview - Scenarios - Practices that helped - Anti-patterns - Applying BDD

Page 3: Pitt agile201505
Page 4: Pitt agile201505
Page 5: Pitt agile201505

“BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.”

--Dan North

Page 6: Pitt agile201505

“BDD’s focus is on the discovery of stuff we didn’t know about, particularly around the contexts in which scenarios or examples take place. …”

--Liz Keogh

Page 7: Pitt agile201505

“Behaviour-driven-development is about implementing an application by describing its behaviour from the perspective of its stakeholders”

--Dan North

Page 8: Pitt agile201505

“BDD practitioners explore, discover, define, and drive out desired behavior of software using conversations, concrete examples, and automated tests” --Matt Wynne

Page 9: Pitt agile201505

Having conversations with domain experts

and using examples

to gain a shared understanding of the desired behavior

and discover unknowns

Page 10: Pitt agile201505

Having conversations with domain experts

and using examples

to gain a shared understanding of the desired behavior

and discover unknowns

Page 11: Pitt agile201505

Having conversations with domain experts

and using examples

to gain a shared understanding of the desired behavior

and discover unknowns

Page 12: Pitt agile201505

Having conversations with domain experts

and using examples

to gain a shared understanding of the desired behavior

and discover unknowns

Page 13: Pitt agile201505

Having conversations with domain experts

and using examples

to gain a shared understanding of the desired behavior

and discover unknowns

Page 14: Pitt agile201505

Building the right thingvs.

building the thing right

Page 15: Pitt agile201505

BDD != toolsand

automation

It’s not all about the tools

Page 16: Pitt agile201505

The best tools won’t solve your customer’s problems if you

don’t know or understandthem

Page 17: Pitt agile201505

If you’re not having conversations

then you’re not doing BDD-- Liz Keogh

Page 18: Pitt agile201505

Having conversations

is more important than capturing conversations

is more important than automating conversations

-- Liz Keogh

Page 19: Pitt agile201505

Scenarios

Page 20: Pitt agile201505

Scenarios are a way for describing behavior

Page 21: Pitt agile201505

Given a contextWhen an event happens

Then an outcome should occur

Page 22: Pitt agile201505

Given Nate purchased a shirt and the shirt cost $20

When he returns the shirtThen he should get $20 refunded

Page 23: Pitt agile201505

“…Simply by getting the business users, the analysts, the testers and the developers to

adopt this vocabulary of “given/when/then”, they discover that a

world of ambiguity falls away.”

-- Dan North

Page 24: Pitt agile201505

Given a contextWhen an event happens

Then an outcome should occur

Page 25: Pitt agile201505

Given a contextWhen an event happens

Then an outcome should occur

Page 26: Pitt agile201505

Given a contextWhen an event happens

Then an outcome should occur

Page 27: Pitt agile201505

Given Nate purchased a shirt and the shirt cost $20

When he returns the shirtThen he should get $20 refunded

Page 28: Pitt agile201505

Is there a context which this event will create a different outcome?

Page 29: Pitt agile201505

Given Nate purchased a shirt for $20and he does not have the receipt

When he returns the shirtThen he should be able to exchange the shirt for another shirt of the same kind

Page 30: Pitt agile201505

Is this the only outcome that matters?

Page 31: Pitt agile201505

Given Nate purchased a shirt for $20and the shirt has a hole in it

and he does not have the receiptWhen he returns the shirt

Then he should be able to exchange the shirt for another shirt of the same kind

and the shirt should be processed as damaged

and the store inventory should be decremented

Page 32: Pitt agile201505

ScenarioDos and Don’ts

Page 33: Pitt agile201505

Make the scenarios user interface

specific

Don’t

Page 34: Pitt agile201505

Given Nate has $20 in his savings accountWhen he navigates to the transfer screenand enters $20 into the transfer amount

text boxand clicks the transfer button

then the account balance should be $40

Don’t

Page 35: Pitt agile201505

Make the scenarios implementation

specific

Don’t

Page 36: Pitt agile201505

Use the language of the business

Do

Page 37: Pitt agile201505

Address multiple domains in a single scenario

Don’t

Page 38: Pitt agile201505

Given Nate purchased a shirt and the shirt cost $20

When he returns the shirtThen he should get $20 refundedand the store inventory should be

incremented by 1

Don’t

Page 39: Pitt agile201505

Keep scenarios simple by focusing on a single domain

at a time

Do

Page 40: Pitt agile201505

Given Nate purchased a shirt and the shirt cost $20

When he returns the shirtThen he should get $20 refunded

Given the store as 10 shirts in inventoryWhen 1 shirt is returned

Then the inventory for that shirt should be 11

Do

Page 41: Pitt agile201505

Add unnecessary or

irrelevant context

Don’t

Page 42: Pitt agile201505

Keep the context to just enough

Do

Page 43: Pitt agile201505

Imperative vs.

declarativescenarios

Page 44: Pitt agile201505

Given John enters john.doe@gmail as the username

and P@55W0rd as the password

When he logs inThen it should be successful

Page 45: Pitt agile201505

Given John has valid credentialsWhen he logs in

Then he it should be successful

Page 46: Pitt agile201505

Acceptance criteria vs.

Scenarios

Page 47: Pitt agile201505

Given Nate purchased a shirt on December 24th 2014

When he returns the shirt on April 28th 2015

Then he should be denied a refund

Page 48: Pitt agile201505

Given a shirt was purchasedwhen it is returned

and the purchase date is older than the allowed time frame

then it should not be refunded

Page 49: Pitt agile201505

Three Amigos

domain expert – developer – tester

Page 50: Pitt agile201505

domain expert

The person who knows the business rules

Page 51: Pitt agile201505

developer

The person who thinks inthe solution space

Page 52: Pitt agile201505

tester

The person who thinks inthe problem space

Page 53: Pitt agile201505

No hand-offs

Page 54: Pitt agile201505

The business writes the scenarios and gives them to the team

Page 55: Pitt agile201505

The developer writes the scenarios without talking to the team

Page 56: Pitt agile201505

The tester writes the scenarios after code finished for automated testing

Page 57: Pitt agile201505

Applying BDD

Page 58: Pitt agile201505

People don’t often speak using Given / When / Then

http://lizkeogh.com/2014/09/01/deriving-gherkin-from-real-conversations/

Page 59: Pitt agile201505

Can you give me an example?

Page 60: Pitt agile201505

What if…?

Page 61: Pitt agile201505

Teams get bored with having conversations

Page 62: Pitt agile201505

Getting buy-in

Page 63: Pitt agile201505

Benefits of BDD

Page 64: Pitt agile201505

Shared understanding

Page 65: Pitt agile201505

Reduces waste / feedback loops

Page 66: Pitt agile201505

Discover unknowns

Page 67: Pitt agile201505

building the right thing

Page 68: Pitt agile201505

Software that matters

Page 69: Pitt agile201505

@njpetersonpa

Page 70: Pitt agile201505

ResourcesDan North - http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/Dan North - http://dannorth.net/whats-in-a-story/Dan North - http://dannorth.net/introducing-bdd/Liz Keogh - http://lizkeogh.com/behaviour-driven-development/Liz Keogh - http://www.slideshare.net/lunivore/behavior-driven-development-11754474Seb Rose - http://www.slideshare.net/sebrose/bdd-history-and-myths