The jury is in. The controversy is over. The debate has ended. The conclusion is: TDD works.
We have knowledge sharing session every two weeks. Normally we just share the new technics we learn in the sprint. This week is different. We watched the famous Uncle Bob’s three TDD rules video.
- You can’t write any production code until you have first written a failing unit test.
- You can’t write more of a unit test than is sufficient to fail, and not compiling is failing.
- You can’t write more production code than is sufficient to pass the currently failing unit test.
The benefits we can get from following these rules are:
- Saving time on debugging.
- Confident. All tests passed means deployment ready.
- Documents itself.
- Testable, because they’re testing ready.
As for me, I do write unit tests but only when the code is completed. Sometimes, we like to ask other team members to write unit tests independently. But this time, I’m really intriged and like to try from next task.
I’ll share my experience also in this article.