What ?
Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle :
- Requirements are turned into very specific test cases
- The software is improved to pass the new tests only.
Why ?
By practicing T.D.D it will :
- Help you to write only the amount of code required to implement a functionnality
- Improve the quality of your code : you will read it like poetry
- Force you to have a direction in mind before you start charging into the fray, and having a direction in mind leads to better design
- Focus you on the value : 100% of testing the wrong things is not a goal…
- Improve your productivity
How ?
- Start to work on a new functionality
- Think about your tests first
- Write your tests and your implementation through T.D.D
- Share with your teammates about your experimentation
TDD cycle
1) Add a test
2) Run all tests and see if the new one fails
3) Write some production code
4) Run tests
5) Refactor code
6) Repeat