25
Behavior-Driven Development As a Developer I want clear requirements So I can build the right stuff Andreas Enbohm @enbohm (screenshot from http://www.thucydides.info / and http ://www.wakaleo.com / )

BDD Short Introduction

Embed Size (px)

DESCRIPTION

A brief intro to Behavior-Driven Development

Citation preview

Page 1: BDD Short Introduction

Behavior-Driven DevelopmentAs a DeveloperI want clear requirementsSo I can build the right stuff

Andreas Enbohm@enbohm

(screenshot from http://www.thucydides.info/ and http://www.wakaleo.com/ )

Page 2: BDD Short Introduction

Succesful IT-Projects

1. Build the software right

2. Build the right software

Page 3: BDD Short Introduction

Succesful IT-Projects

Page 4: BDD Short Introduction

State of Succesful IT-Projects

The 2011 edition of Standish Group’s annual CHAOS Report found that 42% of IT projects were either delivered late, ran over budget, or failed to deliver all of the requested features, and 21% of projects were cancelled entirely.

Page 5: BDD Short Introduction

State of Succesful IT-Projects

Scott Ambler’s annual survey on IT Project success rates found a 30%-50% failure rate depending on the methodologies used.

Page 6: BDD Short Introduction

Used Functionality

Page 7: BDD Short Introduction

The Consequences of Not Building It Right

In December 2007, the Queensland Health department* kicked off work on a new payroll system for its 85,000 employees. The initial budget for the project was around $6 million, with a delivery date scheduled for August 2008. When the solution was rolled out in 2010, some 18 months late, it was a disaster.

Tens of thousands of public servants were underpaid, overpaid, or even not paid at all.Since the go-live date, over 1000 payroll staff are required to carry out some 200,000manual processes each fortnight to ensure that staff salaries are paid. In 2012, anindependent review found that the project had cost the state over $416 million since goinginto production, and would cost an additional $837 million dollars to fix. This colossal sumincluded $220 million just to fix the immediate software issues that were preventing thesystem from delivering its core capability of paying Queensland Health staff what they areowed each month.

* see http://en.wikipedia.org/wiki/Queensland_Health#Payroll_problems

Page 8: BDD Short Introduction

The Consequences of Not Building It Right

Product nobody wants, wrong built.

Page 9: BDD Short Introduction

BDD

Behavior-driven development combines techniques and principles of TDD with ideas from domain-driven design and object-oriented analysis and design, with the aim of delivering "software that matters".

Page 10: BDD Short Introduction

Benefits

• Only build feature that add real value• Less waste (and hence, reduced cost)• Better communication• Higher quality, better tested product• Traceability, ’Live Documentation’• Enables a way to automatic test the

requirements

Page 11: BDD Short Introduction

BDD

• BDD describes TDD done well- removes word ’test’- replace it with behaviour, examples, scenarios etc.

• Good habits;1. Working outside-in2. Using examples to clarify requirements (scenarios)3. Using a common (ubiquitous) language

Page 12: BDD Short Introduction

BDD – Value Driven

• A good goal should add value to business- increase revenue- reduce cost- avoid future cost- protect revenue

”Increase revenue by allowing customers to…”

”Prevent current customers switching to competing product by …”

Page 13: BDD Short Introduction

BDD – What Does the Customer Need?• Good teams push back!

- users tend to express requirements as implementations- we need to find the business need!

We need caching Why?

So that the page loads fast

So that the customer will buy

stuff on our site and doesn’t leave page

Why?

Ok, so to increase the chance a customer will buy [stuff] it need to be ’fast’. Caching

might be one way to achive this, but compressing images might be more

effective. Or another way might be loaders, or ..

Page 14: BDD Short Introduction

BDD – Better understanding• Working outside-in

- if you need to explain to a computer how to check the requirement, you’ll need to be damn sure understand it yourself

• Business black-box testing is often done manually!- BDD enables automated acceptance testing

• Mininum effort /code to fulfull requirement

Page 15: BDD Short Introduction

BDD – Common Language• Common Language

- communication often the biggest overhead- even bigger if you allow different dialects of terminology- takes time but gains significant advantage

Page 16: BDD Short Introduction

BDD

Page 17: BDD Short Introduction

User Stories

“a concise, written description of a piece of functionality that will be valuable to a user (or owner) of the software. It captures the 'who', 'what' and 'why' of a requirement in a simple, concise way.”

Page 18: BDD Short Introduction

User Stories

Story: Returns go to stock

Narrative:In order to keep track of stockAs a store ownerI want to add items back to stock when they're returned

Goal come first

Stakeholder is secondary

The feature must be required to achieve this

goal

Page 19: BDD Short Introduction

Scenarios

• The ’perfect’ bridge between the business-facing and technology-facing sides of a team

Scenario 1: Refunded items should be returned to stock

Given a customer previously bought a black sweater from meAnd I currently have three black sweaters left in stockWhen he returns the sweater for a refundThen I should have four black sweaters in stock

Common language which is reflected all way down in the

code

Page 20: BDD Short Introduction

Why User Stories?

"Maybe it is easier to get users to write down what they need on a card in a few paragraphs than it is to get them to see the difference between uses and extends" - Anonymous

Page 21: BDD Short Introduction

Implementation

Page 22: BDD Short Introduction

http://www.thucydides.info/

Page 23: BDD Short Introduction

http://www.thucydides.info/

Page 24: BDD Short Introduction

Wrap-up

• Pros- increases the quality of the product- change with confidence- live documention (great for maintenance)- less waste, building ”software that matters”

• Cons- high need of business engagemang (clear requirements)- BDD works best in Agile context- easy to write fragile tests (high maintenence cost)

Page 25: BDD Short Introduction

Thank You!