testing requirements with bdd

39
Testing Requirements with BDD Alan Parkinson @alan_parkinson

Upload: alan-parkinson

Post on 28-Jul-2015

256 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Testing requirements with BDD

Testing Requirements with

BDD

Alan Parkinson@alan_parkinson

Page 2: Testing requirements with BDD
Page 3: Testing requirements with BDD

The Requirements Crisis

Page 4: Testing requirements with BDD

We like to solve

complex problems

Page 5: Testing requirements with BDD

Scope creep

Solution

Simple

Page 6: Testing requirements with BDD

Bug Tennis

Developers

Vs

Testers

Page 7: Testing requirements with BDD

The Requirements Crisis

50-60% of all defects are requirement

defects

Page 8: Testing requirements with BDD

A User Story is just a placeholder for a conversation

between the three amigos

Page 9: Testing requirements with BDD

Illusion of transparency

tendency for people to overestimate how well they understand others' personal mental states

Page 10: Testing requirements with BDD

Acceptance Criteria

Rules are difficult to communicate

People end up with a fuzzy understanding

Page 11: Testing requirements with BDD

Can you give me an example?

Upgrade Gold and Platinum Loyalty members to Superior Rooms if

available

Page 12: Testing requirements with BDD

BDD uses examples to illustrate behaviour

Demonstrates how acceptance criteria behaves in a particular situation from a

particular point of view

Page 13: Testing requirements with BDD

BDD uses examples to illustrate behaviour

Given a guest with a standard room reservationAnd the guest is a gold loyalty memberAnd there are superior rooms availableWhen the user checks in the guestAnd a superior room is availableThen the guest should be upgraded to the superior room

Page 14: Testing requirements with BDD

Examples raise questions….

How do we decide if a room is available?

What if a room is not available. Do they get a alternative reward?

Is superior a room type or just any room better than

a standard room?

Page 15: Testing requirements with BDD

Donald Rumsfeld, a BDD thinker

there are known knowns; there are things we know we know.

We also know there are known unknowns; that is to say we know there are some

things we do not know.

But there are also unknown unknowns ”

Page 16: Testing requirements with BDD

There is no such thing as a dumb question

“unknown knowns”

Information we know about but

are not willing to consider… often seen in “group think”

Page 17: Testing requirements with BDD

Deeper examples

Given a guest with a standard room reservationAnd the guest is a gold loyalty memberAnd there are superior rooms availableWhen Roy the receptionist checks in the guestAnd a superior room is availableThen the guest should be upgraded to the superior room

Use real people, roles or actorsGiven a guest with a standard room reservationAnd the guest is a gold loyalty memberAnd there are superior rooms availableWhen Roy the receptionist checks in the guestAnd a superior room is availableThen the guest should be upgraded to the superior room

Given a guest with a standard room reservationAnd the guest is a gold loyalty memberAnd there are superior rooms availableWhen Roy the receptionist checks in the guestAnd a superior room is availableThen the guest should be upgraded to the superior room

Page 18: Testing requirements with BDD

Actors vs Personas

Page 19: Testing requirements with BDD

Deeper examples

Given a guest with a standard room reservationAnd the guest is a gold loyalty memberAnd there are superior rooms availableWhen Roy the receptionist checks in the guestAnd a superior room is availableThen the guest will be upgraded to the superior room

Inject Uncertainly with “should”Given a guest with a standard room reservationAnd the guest is a gold loyalty memberAnd there are superior rooms availableWhen Roy the receptionist checks in the guestAnd a superior room is availableThen the guest should be upgraded to the superior room

Page 20: Testing requirements with BDD

Which come first:Acceptance Criteria or Examples?

Neither!

Both can be used to discover the other

Ask the Product Owner: Can you give

me an example?

Page 21: Testing requirements with BDD

Iterator over the context to discover new Examples

Given a guest with a standard room reservationAnd the guest is a gold loyalty memberAnd there are superior rooms availableWhen the user checks in the guestAnd a superior room is availableThen the guest should be upgraded to the superior room

Given a guest with a standard room reservationAnd the guest is a gold loyalty memberAnd there are superior rooms availableWhen the user checks in the guestAnd a superior room is availableThen the guest should be upgraded to the superior room

Given a guest with a king room reservationAnd the guest is a platinum loyalty memberAnd there are superior rooms availableWhen the user checks in the guestAnd a superior room is availableThen the guest should be upgraded to the superior room

Page 22: Testing requirements with BDD

Examples change our style of writing and

automating

Page 23: Testing requirements with BDD

Given a customer “alan” exists with password “secret”

And I am not logged in

When I navigate to the account page

Then I am redirected to the login form

When I enter the “username” with “alan”

And I enter the “password” with “secret”

And I press “login”

Then I am redirected to my account page

Page 24: Testing requirements with BDD

Given a customer “alan” exists with password “secret”

And I am on the login form

When I enter the “username” with “alan”

And I enter the “password” with “secret”

And I press “login”

...

...

Page 25: Testing requirements with BDD

Imperative style

Command driven, List of instructions, explicit steps on how

to do something

Page 26: Testing requirements with BDD
Page 27: Testing requirements with BDD

Given a customer “alan” exists with password “secret”

And I am not logged in

When I navigate to the account page

Then I am redirected to the login form

When I enter the “username” with “alan”

And I enter the “password” with “secret”

And I press “login”

Then I am redirected to my account page

Page 28: Testing requirements with BDD

What if we wanted to change our Authentication

Method?

We would have to change every mention of the login form

in our tests

Page 29: Testing requirements with BDD

That`s a pretty brittle piece of Automation

Largest cause of Story based Automation failures

Page 30: Testing requirements with BDD

Declarative style

Describes what to do but not how to do it

Page 31: Testing requirements with BDD

“How should it Behave?”

not

“How should I Test it?”

Page 32: Testing requirements with BDD

Given a customer “alan” exists with password “secret”

And I am not logged in

When I navigate to the account page

Then I am redirected to the login form

When I enter the “username” with “alan”

And I enter the “password” with “secret”

And I press “login”

Then I am redirected to my account page

Page 33: Testing requirements with BDD

Given I am an unauthenticated customer

When I attempt to view the account page

Then I am asked to authenticate

When I authenticate with valid customer

credentials

Then I am shown the account page

Page 34: Testing requirements with BDD

Test related details are pushed down into step

implementations

Simple to maintain… Only the step definition

needs to change

Page 35: Testing requirements with BDD

Given a customer “alan” exists with password “secret”

And I am not logged in

Given I am an unauthenticated customer

Page 36: Testing requirements with BDD

When I navigate to the account page

Then I am redirected to the login form

When I attempt to view the account page

Then I am asked to authenticate

Page 37: Testing requirements with BDD

When I enter the “username” with “alan”

And I enter the “password” with “secret”

And I press “login”

When I authenticate with valid customer

credentials

Page 38: Testing requirements with BDD

Questions

Page 39: Testing requirements with BDD

Testing Requirements with

BDD

Alan Parkinson

@alan_parkinson