3 ms·
> I just know intrinsically that they're useless and it's a waste of time. I just know that 95% of my code works and I know what the 5% I'm unsure about is and
by physicles 7y ago
> I just know intrinsically that they're useless and it's a waste of time. I just know that 95% of my code works and I know what the 5% I'm unsure about is and what manual testing or browser testing I need to do to clarify it.
I think this is all based on experience. You know when the tests are going to give you value, because you know when you’ve been burned by a lack of tests in the past. You put tests where you’re worried about bugs appearing.
I write tests when 1) they help me bring up code (you’re gonna do some interactive test/debug cycles in the beginning, might as well do that with tests), or 2) I can’t sleep at night because the code is subtle or complex and I worry about its continued correctness, or 3) there’s a bug and it’s easy to write a regression test for it.
Sometimes writing code without tests is like putting sand into a pile: it works fine for a while, but as soon as you start overloading it, whole faces suddenly shear off. You can shore it up with your hands, but above a certain scale you’re battling to prevent collapse. Tests are like scaffolding you put in place to keep the sand from sliding away.