introduction to behaviour driven development

22
right 2010 Sogeti. All rights reserved. Proprietary and Confidential. BDD Behaviour Driven Development (BDD) The 10 minutes Introduction Christophe Achouiantz – June 2011

Upload: christophe-achouiantz

Post on 13-May-2015

2.962 views

Category:

Technology


2 download

DESCRIPTION

A short introduction to Behaviour Driven Development.

TRANSCRIPT

Page 1: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

BDD

Behaviour Driven Development (BDD)The 10 minutes Introduction

Christophe Achouiantz – June 2011

Page 2: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The need for BDD

Most common impediment for an agile team: Unclear Specifications!

Christophe Achouiantz – June 2011

2023-04-12

Sida 2

Page 3: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

BDD

2006 – Dan North ”TDD/ATDD done well”

“TDD will cause me to have lots of tests, but it won’t necessarily get me nearer the goal of delivering business value through software.”

• Test Driven Development – TDD• Acceptance Test Driven Developement -ATDD

2023-04-12

Sida 3

Christophe Achouiantz – June 2011

Page 4: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

BDD is about Business Value

Behaviour Driven Development

2023-04-12

Sida 4

Christophe Achouiantz – June 2011

Page 5: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

An ”Outside-in” methodology

BDD is an “outside-in” methodology.

Starts at the outside by identifying business outcomes,

and then drills down into the feature set that will achieve those outcomes.

2023-04-12

Sida 5

Christophe Achouiantz – June 2011

Page 6: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Core of BDD: the ”Story”

Each feature is captured as a “story”, which defines the scope of the feature along with its acceptance criteria.

BDD ”Story” = Narative (User Story) +

Acceptance Criteria (Scenarios)

2023-04-12

Sida 6

Christophe Achouiantz – June 2011

Page 7: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Narative: User Stories

User Story as narative (context)

• User centric• Focus on What not so much How• Contains sufficient information so that all

stakeholders understand the context (who, when, what, why)

2023-04-12

Sida 7

Christophe Achouiantz – June 2011

Page 8: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Narative: User Stories

+ Title of the Story +

As a <role>, I want <feature>, So that <benefit>

2023-04-12

Sida 8

Christophe Achouiantz – June 2011

Page 9: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Narative: User Stories

+ Customer withdraws cash + As a customer, I want to withdraw cash from an

ATM, so that I don’t have to wait in line at

the bank.

2023-04-12

Sida 9

Christophe Achouiantz – June 2011

Page 10: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Acceptance Criteria: Scenarios

• A User Story’s behaviour is its acceptance criteria

• Acceptance criteria define the scope of the narative/behaviour

• Acceptance criteria gives us a shared definition of “done”

2023-04-12

Sida 10

Christophe Achouiantz – June 2011

Page 11: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Acceptance Criteria: Scenarios

+ Scenario Title +

Given <context>, When <event>, Then <outcome>

2023-04-12

Sida 11

Christophe Achouiantz – June 2011

Page 12: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Acceptance Criteria: Scenarios

+Scenario 1: Account is in credit+ Given the account is in credit

And the card is valid And the dispenser contains cash,

When the customer requests cash,

Then ensure the account is debited

And ensure cash is dispensed And ensure the card is returned.

2023-04-12

Sida 12

Christophe Achouiantz – June 2011

Page 13: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Acceptance Criteria: Scenarios

+Scenario 2: Account is overdrawn past the overdraft limit+

Given the account is overdrawn

And the card is valid,

When the customer requests cash,

Then ensure a rejection message is displayed

And ensure cash is not dispensed And ensure the card is returned.

2023-04-12

Sida 13

Christophe Achouiantz – June 2011

Page 14: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

The Power of Scenarios

Scenarios =

Test Cases =

Acceptance Criteria2023-04-12

Sida 14

Christophe Achouiantz – June 2011

Page 15: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

A Good Story

1. The title should describe an activity

2. The narrative should include a role, a feature and a benefit

3. The scenario title should say what’s different

4. The scenario should be described in terms of Givens, Events and Outcomes

5. The givens should define all of, and no more than, the required contextThe event should describe the feature

6. The story should be small enough to fit in an iteration

2023-04-12

Sida 15

Christophe Achouiantz – June 2011

Page 16: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

Effect of BDD: A Specification and Ubiquitous Language

BDD Story• Great for discussing with customer, end-

users, other stakeholders• Great for coding, testing, validation

= Specification (by example)

+ Promotes an Ubiquitous Language (everyone speaks the same language!)

2023-04-12

Sida 16

Christophe Achouiantz – June 2011

Page 17: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

BDD is relying on Examples

”Specification by Example”• Examples tell a story about what the system

does• Gojko Adzic

By the way:TDD is then more ”Coding by Example”

• Examples tell a story about what the code does2023-04-12

Sida 17

Christophe Achouiantz – June 2011

Page 18: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

BDD in Practice

• Better requirements workshops / User Stories writing workshops

• Iterative work – clarify requirements:• Write user story + scenarios• Re-write user story (break down?)+ scenarios

• Helps to understand ”What do we want?”• ”Aha!” reaction from participants

• Helps to write clear, concrete requirements

2023-04-12

Sida 18

Christophe Achouiantz – June 2011

Page 19: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

BDD Tools

Automate your Scenarios! Frameworks for:

• Java - JBehave• .Net - SpecFlow• Ruby – Cucumber• Others…

2023-04-12

Sida 19

Christophe Achouiantz – June 2011

Page 20: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

BDD Tools: Cucumber (Ruby)

2023-04-12

Sida 20

Christophe Achouiantz – June 2011

Page 21: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

Starting with BDD

Use Scenarios during your next requirement writing workshop!

2023-04-12

Sida 21

Christophe Achouiantz – June 2011

Page 22: Introduction to Behaviour Driven Development

Copyright 2010 Sogeti. All rights reserved. Proprietary and Confidential.

Happy BDD!

2023-04-12

Sida 22

Christophe Achouiantz – June 2011