Although I love TDD, I don’t always use it for everything. I wrote a Python script the other day to clean up my music collection, and I didn’t write any tests for it.
Someone asked me, what’s the trade-off? At what point do you start writing tests?
For me, it’s at one of a few points:
- Somewhere between 100-200 lines of code I start feeling the need for tests
- When I start feeling unclear in my head, I reach to tests to make them clear
- If someone wants to work with me, tests instantly become mandatory
- When I come back to some code after a while
- When I notice my first bug
What about you? Do you always do TDD? Do you have any rules-of-thumb for when you do?