13 May, 2008<br />Test driven development – <br />“If it&apos;s worth building, it&apos;s worth testing”<br />
Why should we use TDD?<br />Because we can&apos;t we get the design right from the beginning.<br />Why can&apos;t we get t...
What is TDD?<br />Software development technique <br />Related to the test-first programming concepts of Extreme Programmi...
Goals<br />To have a better code coverage test suite<br />To have specification before validation<br />To write clean code...
Principles and general guidelines<br />Write new business code only when an automated test has failed<br />When a test fai...
Development cycle I - Steps<br />Create a test: basically just enough code to fail (testing the test)<br />Run the test to...
Development cycle II <br />13 May, 2008<br />7<br />Test driven development –  “If it&apos;s worth building, it&apos;s wor...
Benefits<br />An interesting side effect of TDD: you achieve 100% coverage test<br />You have a short checklist – resolve ...
Benefits – Safety net<br />Every single piece of functionality added will have a test coverage. If anything ever changes, ...
Benefits – Usable design<br />Code that you develop through TDD is going to end up looking very different from code you wo...
Benefits - Modularity<br />This is another side effect of having to use the code you&apos;re about to write<br />Isolated,...
Benefits – Documentation builds itself<br />The tests you write while doing TDD are the ideal low-level documentation for ...
Misconception<br />The unit tests form 100% of your design specification<br />You only need to do unit test<br />TDD is su...
Tools <br />Visual Studion Team System Test tools<br />NUnit<br />NCover<br />TestDriven.NET<br />13 May, 2008<br />14<br ...
Example using NUnit/VS integrated tool<br />Link to VS Solution<br />13 May, 2008<br />15<br />Test driven development –  ...
References<br />http://www.developer.com/design/article.php/3622546<br />http://homepage.mac.com/hey.you/lessons.html<br /...
17<br />Test driven development –  “If it&apos;s worth building, it&apos;s worth testing”  <br />13 May, 2008<br />
Upcoming SlideShare
Loading in...5
×

Test Driven Development

1,120

Published on

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,120
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
80
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Test Driven Development

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

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

    ×