5. Test Driven Development
- TDD works
1. 3 laws of TDD
- You cannot write production code until you have a failing unit test
- Not more unit test thn it is sufficient to fail
- Not compiling is failing
- Not allowd to write production code than
- That is sufficient to pass failing unit test
The litany of benefits
- Certainty
-
If I make a change, passing test makes code certain
-
Defect injection rate
- Most software can be shipped if unit tests pass
- Courage
- lose fear of making changes
- Documentation
- unit tests are documents
- Design
- When you write tests first
- Coupling of functions is less
- Following 3 laws and writing the tests
- Force you to better decoupled design
- Professional option
- Not using it is unprofessional
2. What TDD is not
- Not a religion
- not a magic formula
- Can even write bad code.