5. Test Driven Development

  • TDD works

1. 3 laws of TDD

  1. You cannot write production code until you have a failing unit test
  2. Not more unit test thn it is sufficient to fail
  3. Not compiling is failing
  4. Not allowd to write production code than
  5. That is sufficient to pass failing unit test

The litany of benefits

  1. Certainty
  2. If I make a change, passing test makes code certain

  3. Defect injection rate

  4. Most software can be shipped if unit tests pass
  5. Courage
  6. lose fear of making changes
  7. Documentation
  8. unit tests are documents
  9. Design
  10. When you write tests first
    1. Coupling of functions is less
  11. Following 3 laws and writing the tests
    1. Force you to better decoupled design
  12. Professional option
  13. Not using it is unprofessional

2. What TDD is not

  • Not a religion
  • not a magic formula
  • Can even write bad code.