ttd test driven development
play

TTD Test-Driven Development Create a formal, executable - PowerPoint PPT Presentation

TTD Test-Driven Development Create a formal, executable specification of what to do What is it TDD is a software development approach whereby you write your test cases before you write any program text TDD2 What


  1. TTD 
 Test-Driven Development � Create a formal, executable specification of what to do � �

  2. What is it �  TDD is a software development approach whereby you write your test cases before you write any program text � � TDD–2

  3. What is it – 2 �  TDD is a software development approach whereby you write your test cases before you write any implementation program text �  You will already have defined the requirement for the class, an initial specification for the class, and an initial design for the class � � TDD–3

  4. What is it – 3 � TDD is a software development approach whereby you write your test  cases before you write any implementation program text �  You will already have defined the requirement for the class, an initial specification for the class, and an initial design for the class �  Tests drive or dictate the order in which the program text is developed � � TDD–4

  5. What is it – 4 � TDD is a software development approach whereby you write your test  cases before you write any implementation program text �  You will already have defined the requirement for the class, an initial specification for the class, and an initial design for the class �  Test cases dictate the order in which the program text is developed �  By the order in which tests are satisfied � � TDD–5

  6. What is it – 5 � TDD is a software development approach whereby you write your test  cases before you write any implementation program text �  You will already have defined the requirement for the class, an initial specification for the class, and an initial design for the class � Test cases dictate the order in which the program text is developed �   By the order in which tests are satisfied �  The intent of the test cases is to �  Provide a formal, executable specification of what a the unit is to do �  As a consequence, Some test cases are �  A part of the specification document for independent features �  A part of the design document to verify consistent and proper implementation � � TDD–6

  7. TDD stages �  Write a single test �  Compile it – compilation will fail, as you have no implementation �  Implement just enough program text to get the test to compile �  Run the test – see it fail �  Implement just enough program text to get the test to pass �  Run the test and it pass �  Refactor �  Repeat � TDD–7

  8. TDD stages � Write a test Refactor & Compile test Run test Fix compile Watch it pass errors Run program test Run test Watch it pass Watch it fail TDD–8

  9. How does this affect you? �  Before you write program text, think about what it will do � TDD–9

  10. How does this affect you? – 2 � Before you write program text, think about what it will do �   Write the test cases that use methods that are not even implemented yet � TDD–10

  11. How does this affect you? – 3 � Before you write program text, think about what it will do �  Write the test cases that use methods that are not even implemented yet �   A test is not something you do it is something you write and run once, twice, three times, etc. etc. etc. � TDD–11

  12. How does this affect you? – � Before you write program text, think about what it will do �  Write the test cases that use methods that are not even implemented yet �   A test is not something you do it is something you write and run once, twice, three times, etc. etc. etc. �  It is program text – a formal, executable specification �  You have test automation so you can repeatedly test your system even after small changes (regression testing) � TDD–12

  13. How does this affect you? – 5 � Before you write program text, think about what it will do �  Write the test cases that use methods that are not even implemented yet �  A test is not something you do it is something you write and run once,  twice, three times, etc. etc. etc. �  It is program text – a formal, executable specification �  You have test automation so you can repeatedly test your system even after small changes (regression testing) �  If a bug is found after development, a test is created to keep the bug from coming back � � TDD–13

  14. Why TDD? �  Programmers dislike testing � TDD–14

  15. Why TDD? – 2 �  Programmers dislike testing �  They will test reasonably thoroughly the first time �  The second time is less thorough �  The third time ... ??? Good luck – testing is a boring task � TDD–15

  16. Why TDD? – 3 �  Programmers dislike testing �  They will test reasonably thoroughly the first time �  The second time is less thorough �  The third time ... ??? Good luck – testing is a boring task �  But programmers need to produce correct program text �  So write the tests first �  Make it easy to run the tests � TDD–16

  17. Why TDD? – 3 �  Encourages programmers to maintain an exhaustive set of repeatable tests � TDD–17

  18. Why TDD? – 4 �  Encourages programmers to maintain an exhaustive set of repeatable tests �  Tests live alongside the class under test �  Tests can be run frequently �  After every single change with XP (extreme programming) �  With tool support, tests can be run selectively �  Making it reasonable to run relevant tests frequently � TDD–18

  19. TDD Benefits �  Fewer bugs �  Program text can be refactored without fear �  Continuous integration �  During development a growing subset of the system always works �  It may not do everything required but what it does do is right �  Program text is more maintainable in that regression testing will find errors due to recent changes � TDD–19

  20. XP approach to testing �  The Extreme Programming approach �  Follows TDD �  Tests are written before the program text itself �  If the program text has no automated test cases, it is assumed not to work �  A testing framework is used so that automated testing can be done � TDD–20

  21. XP approach to testing – 2 �  So what is different? �  Testing is done extremely frequently �  After every change �  This may be as often as every 5 or 10 minutes � TDD–21

  22. XP approach to testing – 3 �  So what is different? �  Testing is done extremely frequently �  After every change �  This may be as often as every 5 or 10 minutes �  A more balanced approach is to run tests frequently but after a coherent set of changes is made � TDD–22

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend