0
Driving application    development throughBehavior Driven Development               by       Einar Ingebrigtsen
Who am I?  Consultant  DoLittle Studios  Silverlight MVP einar@dolittle.com twitter.com/einari http://www.ingebrigtsen.info
Who am I?Author of Balder - 3D engine for Silverlighthttp://balder.codeplex.comCo-author of Bifrost - enterprise app frame...
Win a Typemock Isolator /   Isolator++ License During the webinar, tweet one cool takeaway or one tip that you learn with ...
Retro-style   testing, 1996
9 phases of unit testing•   What is unit testing?•   Refuse to unit test because “you don’t have enough time”.•   Fight it...
Why• Improve quality• Add predictability• Add changeability• Safety net
Test first “One of the most useful times to write tests is beforeyou start programming. When you need to add a feature,    ...
Continuous• Your tests are worthless without them being  executed at a certain frequency• Integrate your tests and product...
The 10th phase
... orskip all 9...
Lets talk about  behaviors...
Background• Coined by Dan North in 2006 article in Better Software magazine• Reaction to TDD• Focus on behaviors of your s...
Dialogue• Improves the dialog with non-developers• Mindset puts the developer closer to business value• Easier for other d...
Mindset• Focus on business value; hence behavior in the system• Your system doesn’t work with data - but behavior that mig...
Where does it apply?• In short; everywhere• It fits perfectly for anything ranging from  acceptance to unit level• In fact;...
Gherkin• Business readable DSL• Introduced by Aslak Hellesøy for Cucumber in 2008
GherkinFeature: Addition  In order to avoid silly mistakes  As a math idiot  I want to be told the sum of two numbersScena...
GherkinFeature: Addition  In order to avoid silly mistakes  As a math idiot  I want to be told the sum of two numbersScena...
Units• Test behavior of the unit• Tests interaction between systems• Focus on decoupling
Test Doubles• Provide implementations of dependent systems that are not real systems• Good for decoupling
Fakes• Working implementations• Usually takes shortcuts unsuitable for  production • In-memory database representations
Stubs• Provide canned answers• May record information about calls being made to it
Mocks• Objects preprogrammed with expectations• Often created adhoc by utilizing frameworks : • TypeMock • RhinoMocks • Mo...
Writing testable code• Apply practices such as dependency  inversion principle • Makes your code decoupled from real   imp...
This changes everything
do e        sn’tThis changes everything
Writing testable code• Your code will change - but its a good  thing, its not only for your tests!• The principles that ca...
Frameworks?• You can use your existing - remember; its a mindset, not a framework!• NBehave• MSpec
Structure(project to specify).Specs  (namespace)      for_(unit to specify)          given              a_(context).cs    ...
Structure                               sample Bifrost.SpecsCommands  for_CommandContext    given      a_command_context_f...
Frameworks• SpecFlow• StoryQ• Cuke4Nuke
Feedback Loop• Built-in test runner in Visual Studio is  slow• TestDriven.net - great alternative• Auto-test running • Mig...
Recommended          reading• Dan Norths blog  http://dannorth.net/introducing-bdd/• http://pragprog.com/book/hwcuc/the-cu...
.. one more thing ..
.. go and create software     with less bugs.. :)
Driving application development through behavior driven development
Driving application development through behavior driven development
Driving application development through behavior driven development
Upcoming SlideShare
Loading in...5
×

Driving application development through behavior driven development

1,109

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,109
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
25
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Driving application development through behavior driven development"

    1. 1. Driving application development throughBehavior Driven Development by Einar Ingebrigtsen
    2. 2. Who am I? Consultant DoLittle Studios Silverlight MVP einar@dolittle.com twitter.com/einari http://www.ingebrigtsen.info
    3. 3. Who am I?Author of Balder - 3D engine for Silverlighthttp://balder.codeplex.comCo-author of Bifrost - enterprise app frameworkhttp://bifrost.dolittle.comCo-author of Forseti - headless JS test runnerhttp://github.com/dolittlestudios/forseti
    4. 4. Win a Typemock Isolator / Isolator++ License During the webinar, tweet one cool takeaway or one tip that you learn with the hashtag #unittesting and @typemock. Typemock will then choose a winner and announce them next week.
    5. 5. Retro-style testing, 1996
    6. 6. 9 phases of unit testing• What is unit testing?• Refuse to unit test because “you don’t have enough time”.• Fight it because it means writing more code• Start unit testing and start blogging / talking about unit testing and TDD and how great it is• Unit test everything - make private methods internal and abuse things like InternalVisibleTo attribute. 100% codecoverage is the only way to fly• Discover mocking and abuse it• Mock everything that is possible to be mocked (like the entire .net framework)• Start writing effective tests• Enjoy others trying to figure out why you hardly have any bugs at all
    7. 7. Why• Improve quality• Add predictability• Add changeability• Safety net
    8. 8. Test first “One of the most useful times to write tests is beforeyou start programming. When you need to add a feature, begin by writing the test. By writing the test you are asking yourself what needs to be done.” Martin Fowler
    9. 9. Continuous• Your tests are worthless without them being executed at a certain frequency• Integrate your tests and production code often and have your tests along with others run frequently
    10. 10. The 10th phase
    11. 11. ... orskip all 9...
    12. 12. Lets talk about behaviors...
    13. 13. Background• Coined by Dan North in 2006 article in Better Software magazine• Reaction to TDD• Focus on behaviors of your system
    14. 14. Dialogue• Improves the dialog with non-developers• Mindset puts the developer closer to business value• Easier for other developers to read• Easier to get started with testing
    15. 15. Mindset• Focus on business value; hence behavior in the system• Your system doesn’t work with data - but behavior that might result in data
    16. 16. Where does it apply?• In short; everywhere• It fits perfectly for anything ranging from acceptance to unit level• In fact; you might want to stribe towards using BDD consistently
    17. 17. Gherkin• Business readable DSL• Introduced by Aslak Hellesøy for Cucumber in 2008
    18. 18. GherkinFeature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbersScenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen
    19. 19. GherkinFeature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbersScenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen
    20. 20. Units• Test behavior of the unit• Tests interaction between systems• Focus on decoupling
    21. 21. Test Doubles• Provide implementations of dependent systems that are not real systems• Good for decoupling
    22. 22. Fakes• Working implementations• Usually takes shortcuts unsuitable for production • In-memory database representations
    23. 23. Stubs• Provide canned answers• May record information about calls being made to it
    24. 24. Mocks• Objects preprogrammed with expectations• Often created adhoc by utilizing frameworks : • TypeMock • RhinoMocks • Moq • ... and more ...
    25. 25. Writing testable code• Apply practices such as dependency inversion principle • Makes your code decoupled from real implementations• In short - S.O.L.I.D. prinicples will get you there...
    26. 26. This changes everything
    27. 27. do e sn’tThis changes everything
    28. 28. Writing testable code• Your code will change - but its a good thing, its not only for your tests!• The principles that can be applied are good software development principles, regardless of testing or not
    29. 29. Frameworks?• You can use your existing - remember; its a mindset, not a framework!• NBehave• MSpec
    30. 30. Structure(project to specify).Specs (namespace) for_(unit to specify) given a_(context).cs when_(behavior to specify).cs
    31. 31. Structure sample Bifrost.SpecsCommands for_CommandContext given a_command_context_for_a_simple_command_with_one_tracked_object.cs when_committing.cs
    32. 32. Frameworks• SpecFlow• StoryQ• Cuke4Nuke
    33. 33. Feedback Loop• Built-in test runner in Visual Studio is slow• TestDriven.net - great alternative• Auto-test running • Mighty Mooze - Continuous Test http://continuoustests.com/ • NCrunch http://www.ncrunch.net/
    34. 34. Recommended reading• Dan Norths blog http://dannorth.net/introducing-bdd/• http://pragprog.com/book/hwcuc/the-cucumber-book The Cucumber book• The RSpec book http://pragprog.com/book/achbd/the-rspec-book
    35. 35. .. one more thing ..
    36. 36. .. go and create software with less bugs.. :)
    1. A particular slide catching your eye?

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

    ×