behaviour-driven developmentjaoo.dk/dl/qcon-london-2008/slides/aslakhellesoy... · behaviour-driven...
TRANSCRIPT
![Page 1: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/1.jpg)
Behaviour-Driven DevelopmentWriting software that matters
Aslak Hellesøy - Chief Scientist - BEKK
![Page 2: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/2.jpg)
2
Dual audience
Stakeholders
Programmers
![Page 3: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/3.jpg)
Origin and inspiration
JBehaveDan NorthChris Matts
Test Driven Development
Kent Beck
FITWard
Cunningham
User StoriesMike Cohn
Example Driven DevelopmentBrian Marick
Chelimsky, Hellesøy, Takita, Astels, Baker
Connextra StoriesSeveral
Domain Driven Design
Eric Evans
Acceptance-Test Driven
Planning
![Page 4: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/4.jpg)
4
Software development is all about delivering
business value
![Page 5: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/5.jpg)
What’s being used
Source: CHAOS report
![Page 6: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/6.jpg)
Where errors are introduced
Source: CHAOS report
![Page 7: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/7.jpg)
![Page 8: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/8.jpg)
8
BDD: Business value
![Page 9: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/9.jpg)
![Page 10: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/10.jpg)
10
Ubiqutous Language
![Page 11: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/11.jpg)
BDD User Stories
Withdraw Cash
As an Account Holder
I want to withdraw cash in an ATM
So that I can get cash when the bank
is closed
Role
Operation
Business value1
![Page 12: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/12.jpg)
Origin: Connextra
![Page 13: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/13.jpg)
13
Challenge:Common understanding
of “Done”
![Page 14: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/14.jpg)
BDD Scenarios
Business value
1
Given I have £200 in my accountWhen I ask to withdraw £20Then I should be given £20And my balance should be £180
![Page 15: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/15.jpg)
ATDPAcceptance-Test Driven Planning
WriteScenarios
Product Backlog
IterationPlanning
Iteration N (end) Iteration N+1 (start)
![Page 16: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/16.jpg)
TDD
Red
Green
Refactor
Make the
test pass
Write a
failing
test
Write a
passing test
1 2
3?
![Page 17: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/17.jpg)
Developers don’t know...
• Where to start
• What to test
• What not to test
• How much to test in one go
• What to call tests
• How to fix a broken test
• That TDD is about design
![Page 18: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/18.jpg)
Outside-In
2
3
4
5
1
![Page 19: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/19.jpg)
![Page 20: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/20.jpg)
0
10,000
20,000
30,000
40,000
June 2007 February 2008
Downloads
0
25
50
75
100
June 2007 February 2008
Contributors
0
10
20
30
40
June 2007 February 2008
RubyForge rank
0
828.25
1,656.50
2,484.75
3,313.00
June 2007 February 2008
SVN commits
![Page 21: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/21.jpg)
JRuby << RSpec
![Page 22: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/22.jpg)
RSpec consists of 2 parts
Story Framework
Example Framework
![Page 23: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/23.jpg)
Story: Log in
As a Project contributor I want to log in So that I can see what projects I have access to Scenario: User provides wrong credentials Given I am on the login page When I log in with login nobody and password useless Then I should be informed that my password is incorrect And I should not see aslak.hellesoy on the page
Scenario: User provides correct credentials Given I am on the login page When I log in with login aslak.hellesoy and password temporary Then I should see aslak.hellesoy on the page And I should have the opportunity to log out
RSpec User Stories
![Page 24: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/24.jpg)
require 'bowling'
describe Bowling do before(:each) do @bowling = Bowling.new end
it "should score 0 for gutter game" do 20.times { @bowling.hit(0) } @bowling.score.should == 0 endend
RSpec Examples
![Page 25: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/25.jpg)
Outside-In
2
3
4
5
Story: Withdraw Money
As an account holder
I want to withdraw money
So that I can get cash when the bank is closed
Scenario: Overdraft account
Given an account with -1000 kr
When I ask for 200 kr
Given the balance should be -1000 kr
1
describe Bank do
it "should not be creatable with negative balance" do
lambda do
Bank.new(-9)
end.should(raise_error("Negative balance"))
end
end
![Page 26: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/26.jpg)
Summary
• As a <Role>, I want <Operation> So that <Business value>
• Given <Known state>, When I <Action>, Then <Expected outcome>
• Work Outside-in in the layer onion
• Write scenarios and tests bottom up (start with outcome)
• Tests are sentences
![Page 27: Behaviour-Driven Developmentjaoo.dk/dl/qcon-london-2008/slides/AslakHellesoy... · Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK](https://reader035.vdocuments.net/reader035/viewer/2022062306/5f0cf71e7e708231d438022b/html5/thumbnails/27.jpg)
References
• http://behaviour-driven.org/
• http://dannorth.net/introducing-bdd/
• http://dannorth.net/whats-in-a-story/
• http://rspec.info/
• http://jtestr.codehaus.org/
• http://jruby.codehaus.org/
• http://blog.aslakhellesoy.com/