14. What exactly is this TDD thingy?
❖ Test-Driven Development (TDD) is a technique for
building software that guides software development by
writing tests. (Martin Fowler’s definition)
15. TDD? But I already write unit tests!
Pants == TDD
Shoes == Unit tests!
16. TDD is mainly about design!
❖ “Test Driven Development” is NOT primarily about
testing or development (i.e., coding)
17. Who writes unit tests?
❖ Developers write unit tests (NOT testers) and then code
19. Step 1: Write test that fails
❖ Red—write a little test that doesn’t work, perhaps
doesn’t even compile at first
Source: Test Driven Development: By Example, Kent Beck, 240 pages, Addison-Wesley Professional, 2002;
20. Step 2: Get code working to pass test
❖ Green—make the test work quickly, committing
whatever sins necessary in the process
Source: Test Driven Development: By Example, Kent Beck, 240 pages, Addison-Wesley Professional, 2002;
21. Step 3: Cleanup and refactor
❖ Refactor—eliminate all the duplication and smells created
in just getting the test to work
Source: Test Driven Development: By Example, Kent Beck, 240 pages, Addison-Wesley Professional, 2002;
32. Newton’s first law of testto dynamics: You may not write production
code unless you’ve first written a failing unit test.
Source: Professionalism and Test-Driven Development, Robert C. Martin, IEEE Software, 2007
33. Newton’s second law of testto dynamics: You may not write more of a
unit test than is sufficient to fail.
Source: Professionalism and Test-Driven Development, Robert C. Martin, IEEE Software, 2007
34. Newton’s third law of testto dynamics: You may not write more
production code than is sufficient to make the failing unit test pass.
Source: Professionalism and Test-Driven Development, Robert C. Martin, IEEE Software, 2007