Re:What TDD Is Good For
by herpdyderp on Tuesday December 10, 2024 @12:17AM
(#42373997)
It's also a great way to codify "hey we found this edge case once" and make sure it doesn't happen again.
That's the only type of test I know for sure has value, which makes them easy to write.
At work I feel a certain pressure to test more or less everything, but personally I much prefer a "common sense"-approach: Writing tests is motivated by either bugs found (including any issues you run into during the initial implementation) and/or complex operations that are easy to get wrong and could need the extra documentation that tests provide.
I dispise aiming for 100% code completion, so much of that is just idealism and wasteful.
Not just regressions, but bugs in general.
If you can reproduce your bug in a test, then verify that your fix causes your test to pass, that's a great way to build confidence before trying out your code in production.
And in fact, this is mentioned in the article as part of maintenance:
> Writing a test first to prove out a bug before you fix it is pretty neat.