Your SlideShare is downloading. ×
Test Driven Development
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Test Driven Development

1,020
views

Published on

Why should you use test driven development? Goals, benefits, principles, guidelines and tools.

Why should you use test driven development? Goals, benefits, principles, guidelines and tools.

Published in: Technology, Business

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,020
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
77
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Transcript

    • 1. 13 May, 2008
      Test driven development –
      “If it's worth building, it's worth testing”
    • 2. Why should we use TDD?
      Because we can't we get the design right from the beginning.
      Why can't we get the design right from the beginning?
      Because at the start of the project we have imperfect knowledge about the software we're developing.
      13 May, 2008
      Test driven development – “If it's worth building, it's worth testing”
      2
    • 3. What is TDD?
      Software development technique
      Related to the test-first programming concepts of Extreme Programming
      TDD = TFD + Refactoring
      13 May, 2008
      3
      Test driven development – “If it's worth building, it's worth testing”
    • 4. Goals
      To have a better code coverage test suite
      To have specification before validation
      To write clean code that works
      But the real benefits are many more than the goals!
      13 May, 2008
      4
      Test driven development – “If it's worth building, it's worth testing”
    • 5. Principles and general guidelines
      Write new business code only when an automated test has failed
      When a test fails you have made progress because you now know that you need to resolve the problem
      TDD does not replace traditional testing, instead it defines a proven way to ensure effective unit testing.
      If it's worth building, it's worth testing.
      If it's not worth testing, why are you wasting your time working on it?
      13 May, 2008
      5
      Test driven development – “If it's worth building, it's worth testing”
    • 6. Development cycle I - Steps
      Create a test: basically just enough code to fail (testing the test)
      Run the test to ensure that the test does in fact fail (testing the test)
      Run minimal code necessary to pass the test
      Refactor the code
      Clean up
      Remove duplication
      Write a new test case ….
      13 May, 2008
      6
      Test driven development – “If it's worth building, it's worth testing”
    • 7. Development cycle II
      13 May, 2008
      7
      Test driven development – “If it's worth building, it's worth testing”
    • 8. Benefits
      An interesting side effect of TDD: you achieve 100% coverage test
      You have a short checklist – resolve one piece of functionality at a time
      Cleaner design than achieved by other methods
      The design is easier to understand
      The code becomes easier to work with as the project matures
      The resulting code is designed for testability
      13 May, 2008
      8
      Test driven development – “If it's worth building, it's worth testing”
    • 9. Benefits – Safety net
      Every single piece of functionality added will have a test coverage. If anything ever changes, the developer will know right away
      Better assurance when integrating your code into source control
      Refactoring becomes a lot easier, so the codebase can be kept always healthy
      13 May, 2008
      9
      Test driven development – “If it's worth building, it's worth testing”
    • 10. Benefits – Usable design
      Code that you develop through TDD is going to end up looking very different from code you would have written otherwise
      You don't start with a UML diagram, or a detailed class header file, or anything like that
      You start by using the feature you're about to implement
      You're going to be your first user of your code, and you're going to think about how to use it from the beginning
      13 May, 2008
      10
      Test driven development – “If it's worth building, it's worth testing”
    • 11. Benefits - Modularity
      This is another side effect of having to use the code you're about to write
      Isolated, modular tests => modular codebase
      A highly modular codebase will compile much more quickly than one that has grown organically
      13 May, 2008
      11
      Test driven development – “If it's worth building, it's worth testing”
    • 12. Benefits – Documentation builds itself
      The tests you write while doing TDD are the ideal low-level documentation for your code
      For every feature, you have at least one example on how to use it correctly and how it's expected to be used.
      And the best part is that it can't ever get out of date.
      13 May, 2008
      12
      Test driven development – “If it's worth building, it's worth testing”
    • 13. Misconception
      The unit tests form 100% of your design specification
      You only need to do unit test
      TDD is sufficient for testing
      TDD doesn'tscale
      Your test suite takes too long to run
      Not all developers know how to test. 
      Everyone might not be taking a TDD approach.
      13 May, 2008
      13
      Test driven development – “If it's worth building, it's worth testing”
    • 14. Tools
      Visual Studion Team System Test tools
      NUnit
      NCover
      TestDriven.NET
      13 May, 2008
      14
      Test driven development – “If it's worth building, it's worth testing”
    • 15. Example using NUnit/VS integrated tool
      Link to VS Solution
      13 May, 2008
      15
      Test driven development – “If it's worth building, it's worth testing”
    • 16. References
      http://www.developer.com/design/article.php/3622546
      http://homepage.mac.com/hey.you/lessons.html
      http://www.gamesfromwithin.com/articles/0502/000073.html
      http://msdn2.microsoft.com/en-us/magazine/cc163982.aspx
      http://www.artima.com/intv/testdriven2.html
      http://www.parlezuml.com/tutorials/agiledotnet/tdd_nunit.pdf
      http://en.wikipedia.org/wiki/Test-driven_development
      13 May, 2008
      16
      Test driven development – “If it's worth building, it's worth testing”
    • 17. 17
      Test driven development – “If it's worth building, it's worth testing”
      13 May, 2008