Behaviour-Driven
 Development
    Writing software that matters
Aslak Hellesøy - Chief Scientist - BEKK
Stakeholders


               Programmers

      Dual audience

                        2
Origin and inspiration
 JBehave         Test Driven       FIT
Dan North       Development       Ward
Chris Matts       Ken...
Software development is
   all about delivering
      business value


                     4
What’s being
  used




               Source: CHAOS report
Where
 errors are
introduced




              Source: CHAOS report
BDD: Business value



                      8
Ubiqutous Language



                     10
BDD User Stories
Withdraw Cash
                  Role
As an Account Holder        Operation
I want to withdraw cash in an ...
Origin: Connextra
Challenge:
Common understanding
    of “Done”


                  13
BDD Scenarios

Given I have £200 in my account
When I ask to withdraw £20
Then I should be given £20
And my balance should...
ATDP
Acceptance-Test Driven Planning


               Product Backlog

   Write                          Iteration
 Scenar...
TDD
               Red
  1                         2
Write a                 Make the
failing                 test pass
 t...
Developers don’t know...
• Where to start
• What to test
• What not to test
• How much to test in one go
• What to call te...
Outside-In

1
    2
        3
            4
                5
Downloads                         Contributors
 40,000                                100

 30,000                        ...
JRuby << RSpec
RSpec consists of
       2 parts

Story Framework

    Example Framework
RSpec User Stories
Story: Log in

  As a Project contributor
  I want to log in
  So that I can see what projects I have a...
RSpec Examples
require 'bowling'

describe Bowling do
  before(:each) do
    @bowling = Bowling.new
  end

  it quot;shoul...
Outside-In
Story: Withdraw Money

  As an account holder
  I want to withdraw money
                                      ...
Summary
• As a <Role>, I want <Operation> So that
  <Business value>
• Given <Known state>, When I <Action>,
  Then <Expec...
References
• http://behaviour-driven.org/
• http://dannorth.net/introducing-bdd/
• http://dannorth.net/whats-in-a-story/
•...
Aslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec Bdd
Upcoming SlideShare
Loading in...5
×

Aslak Hellesoy Executable User Stories R Spec Bdd

4,690

Published on

Published in: Business, Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,690
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
124
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Aslak Hellesoy Executable User Stories R Spec Bdd

  1. 1. Behaviour-Driven Development Writing software that matters Aslak Hellesøy - Chief Scientist - BEKK
  2. 2. Stakeholders Programmers Dual audience 2
  3. 3. Origin and inspiration JBehave Test Driven FIT Dan North Development Ward Chris Matts Kent Beck Cunningham Example Driven Chelimsky, User Stories Development Hellesøy, Takita, Mike Cohn Brian Marick Astels, Baker Connextra Domain Driven Acceptance- Stories Design Test Driven Several Eric Evans Planning
  4. 4. Software development is all about delivering business value 4
  5. 5. What’s being used Source: CHAOS report
  6. 6. Where errors are introduced Source: CHAOS report
  7. 7. BDD: Business value 8
  8. 8. Ubiqutous Language 10
  9. 9. BDD User Stories Withdraw Cash Role As an Account Holder Operation I want to withdraw cash in an ATM So that I can get cash when the bank is closed 1 Business value
  10. 10. Origin: Connextra
  11. 11. Challenge: Common understanding of “Done” 13
  12. 12. BDD Scenarios Given I have £200 in my account When I ask to withdraw £20 Then I should be given £20 And my balance should be £180 1 Business value
  13. 13. ATDP Acceptance-Test Driven Planning Product Backlog Write Iteration Scenarios Planning Iteration N (end) Iteration N+1 (start)
  14. 14. TDD Red 1 2 Write a Make the failing test pass test Green ? 3 Write a Refactor passing test
  15. 15. 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
  16. 16. Outside-In 1 2 3 4 5
  17. 17. Downloads Contributors 40,000 100 30,000 75 20,000 50 10,000 25 0 0 June 2007 February 2008 June 2007 February 2008 SVN commits RubyForge rank 3,313.00 40 2,484.75 30 1,656.50 20 828.25 10 0 0 June 2007 February 2008 June 2007 February 2008
  18. 18. JRuby << RSpec
  19. 19. RSpec consists of 2 parts Story Framework Example Framework
  20. 20. RSpec User Stories 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
  21. 21. RSpec Examples require 'bowling' describe Bowling do before(:each) do @bowling = Bowling.new end it quot;should score 0 for gutter gamequot; do 20.times { @bowling.hit(0) } @bowling.score.should == 0 end end
  22. 22. Outside-In Story: Withdraw Money As an account holder I want to withdraw money 1 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 2 describe Bank do it quot;should not be creatable with negative balancequot; do lambda do 3 Bank.new(-9) end.should(raise_error(quot;Negative balancequot;)) end 4 end 5
  23. 23. 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
  24. 24. 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/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×