Behaviour Driven Development
Behaviour Driven Development
http://blog.jonasbandi.net http://gasparnagy.blogspot.com
[email protected] [email protected]
twitter: @jbandi twitter: @gasparnagy
BDD?
BDD? – BUSHIDO DRIVEN DEVELOPMENT
Write good
code or kill
yourself out
of shame.
@durp
Boss Driven
Development
Beer Driven
Development
Ah ok... I understand. It is done!"
2000 2008
Project success, Chaos Report, Standish Group
What
Why is the
does problem?
software fail?
Therac-25, radiation therapy machine (1985)
"I believe that the hardest
part of software projects,
the most common source
of project failure, is
communication with the
customers and users of
that software."
- Martin Fowler, DSL Book
WHAT DEFINES SUCCESSFUL SOFTWARE?
Level of Detail
What? Detail Specification
,,Scope”
Communication
Gap!
Realization
How?
,,Details” Code
How?
Predictability Quantity
ABSTRACTION DURING ANALYSIS
THE TRADITIONAL APPROACH
TELEPHONE GAME
http://www.brokenpicturetelephone.com
TELEPHONE GAME
Executable test-based
specifications
Pic: Martin/Melnik: Requirements and
Tests
BDD?
BDD – A DEFINITION FROM NORTH
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, Agile Testing, Specifications and BDD Exchange 2009
BDD: AN ATTEMPT TO FIT IT ALL TOGETHER
Specification by
TDD Example
Test Driven Development Definition of
Done
DDD
Domain Driven Design BDD ATDD
Behavior Driven Acceptance Test Driven
DSL Development Development
Domain Specific Language
Business Goals
Formalized
Concrete and Actor-Goals
Level of Detail
Epics
consistent
User Stories
Communication
Verifiable
Gap!
Acceptance
Bugs
Up-to-date Criteria
Just in time
Code
How?
Predictability Quantity
EXAMPLE: USER STORIES
Why?
As a potential customer
I want to search for books by a simple string
So that I can easily allocate books by somethingBusiness
I Goals
Level of Detail
Epics
Communication
I want to place books into my shopping basket
Gap!
So that I can order several books at once. Acceptance
Criteria
Code
How?
Predictability Quantity
EXAMPLE: ACCEPTANCE CRITERIA
Why?
As a potential customer
I want to place books into my shopping basket
So that I can order several books at once. Business Goals
Actor-Goals
Level of Detail
Epics
Books can be added to basket.
User Stories
Communication
Basket should be empty initially.
Gap!
Acceptance
Criteria
Books can be removed from basket.
How?
Predictability Quantity
SPECIFICATION BY EXAMPLE
• Abstract requirements and
specifications are not a good tool for
communication.
• Concrete examples are much better.
• Usually examples are not formalized
and not shared.
are composed of
Examples Tests
elaborate verify & validate
Requirements
EXAMPLES AS ACCEPTANCE CRITERIA
As a potential customer
I want to place books into my shopping basket
So that I can order several books at once.
UI
System
Automation
Automation
Schnittstelle
SPECFLOW
Open-source BDD tool for .NET
www.specflow.org
github.com/techtalk/SpecFlow
www.cukes.info
http://github.com/aslakhellesoy/gherkin/
GHERKIN EXAMPLE
GHERKIN KEYWORDS
Feature
Scenario
Given,When,Then,And,But
Background
Scenario-Outline, Examples
AccCrit 1 AccCrit 1
User Story 1
AccCrit 2 „Done“ AccCrit 2
Feature 1
AccCrit 3 AccCrit 3
User Story 2
AccCrit 4 AccCrit 5
AccCrit 5 AccCrit 4
User Story n Feature n
AccCrit m AccCrit m
Cuke4Nuke
http://github.com/richardlawrence/Cuke4Nuke/
• BDD extension for xUnit
NBehave http://code.google.com/p/xunitbddextensions/
http://nbehave.org/
Fit/Fitnesse
http://nbehave.org/
StorEvil
http://wiki.github.com/davidmfoley/storevil/
• Nspec
StoryQ http://nspec.tigris.org/
http://storyq.codeplex.com/
Specter • SpecUnit.Net
http://code.google.com/p/specunit-net/
http://specter.sourceforge.net/
Aubergine
github.com/ToJans/Aubergine
GHERKIN TOOLS
Cuke4Vs
http://github.com/henritersteeg/cuke4vs
Gherkin Editor
http://gherkineditor.codeplex.com/
NetBeans Plugin
JetBrain RubyMine
TextMate Bundle
Vim integration
MORE INFO
www.specflow.org
http://github.com/techtalk/SpecFlow
http://github.com/techtalk/SpecFlow-Examples
http://groups.google.com/group/specflow/
http://wiki.github.com/aslakhellesoy/cucumber/
http://tekpub.com/view/concepts/5
http://blog.stevensanderson.com/2010/03/03/behavior-driven-
development-bdd-with-specflow-and-aspnet-mvc/
http://www.codeproject.com/KB/architecture/BddWithSpecFlow.aspx
http://bitbucket.org/rstuven/steckbrett.specssupport/src
TechTalk offers:
Workshops for:
Agile Requirements Analysis
Implementing BDD
FRAGEN UND DISKUSSION