Behaviour-Driven Development

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    Short presentation on how BDD evolved, then demo using RSpec.

    1 Favorite

    Behaviour-Driven Development - Presentation Transcript

    1. Behaviour-Driven Development
      • Kerry Buckley
    2. Evolution
    3. Dirty Hacking
    4. Automated Testing
    5. Automated Testing class Adder def add a, b a + b end end class AdderTest < Test::Unit::TestCase def test_adder adder = Adder . new assert_equal 4 , adder.add( 2 , 2 ) assert_equal 2 , adder.add( 4 , - 2 ) end end
    6. Are You Really Testing Your Code? class Adder def add a, b a + b end end class AdderTest < Test::Unit::TestCase def test_adder assert_equal 4 , 2 + 2 end end
    7. Test-First Development
    8. Test-First Development Failing tests Start Done Write code Write tests
    9. Test-Driven Development
    10. Test-Driven Development Failing test Clean code All tests pass Refactor
    11. State-Based class DongleTest < Test::Unit::TestCase def test_wibble # Set up test inputs dongle = Dongle . new dongle.addString( &quot;foo&quot; ) dongle.addRemoteResource( &quot; http://foo.com/bar &quot; ) # Exercise functionality under test dongle.wibble! # Verify results are as expected dongle.answer.should == 42 end end
    12. Bottom-Up
    13. Behaviour-Driven Development
    14. Behaviour-Driven Development Verification Specification State-based Interaction-based Bottom-up Outside-in Testing tool Design tool Invention Discovery
    15. More Descriptive Test Names class AdderTest < Test::Unit::TestCase def test_should_add_two_positive_numbers assert_equal 4 , Adder . new .add( 2 , 2 ) end def test_should_add_a_positive_and_a_negative_number assert_equal 2 , Adder . new .add( 4 , - 2 ) end end
    16. Matchers describe &quot;An adder&quot; do it &quot;should add two positive numbers&quot; do Adder . new .add( 2 , 2 ).should == 4 end it &quot;should add a positive and a negative number&quot; do Adder . new .add( 4 , - 2 ).should == 2 end end
    17. Generated Documentation $ spec -f s adder_spec.rb An adder - should add two positive numbers - should add a positive and a negative number Finished in 0.005493 seconds 2 examples, 0 failures
    18. More Matcher Examples @string .should == &quot;foo&quot; @array .should_not be_empty @hash .should have_key( :foo ) @object .should be_an_instance_of String lambda { @stack .pop }.should raise_error( StackUnderflowError )
    19. Top-Down
    20. Interaction-Based
    21. Mock Objects
      • Stand-ins for collaborating objects
      • Mock the interface, not a specific object
      • Verify that expected calls are made
      • Not stubs!
      • For your code only!
    22. Classicists v Mockists
    23. Mock Objects Mock Mock
    24. Boundary Objects
    25. Integration Testing
    26. Further Reading Introducing BDD (Dan North) http: //dannorth . net/introducing-bdd BDD Introduction http: //behaviour-driven .org/Introduction Mock Roles, Not Objects (Freeman, Mackinnon, Pryce, Walnes) http://www. jmock .org/oopsla2004. pdf BDD in Ruby (Dave Astels) http: //blog . daveastels . com/files/BDD_Intro . pdf

    + Kerry BuckleyKerry Buckley, 2 years ago

    custom

    1172 views, 1 favs, 2 embeds more stats

    Slides from a talk to Web21C SDK team.

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1172
      • 1168 on SlideShare
      • 4 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 69
    Most viewed embeds
    • 2 views on http://confluence.jnpr.net
    • 2 views on https://confluence.jnpr.net

    more

    All embeds
    • 2 views on http://confluence.jnpr.net
    • 2 views on https://confluence.jnpr.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories