I'm the world's biggest fan of unit tests, but one minor drawback I've noticed is they encourage some sort of intellectual sloppiness with bugs... it's too easy to fix bugs by just meander around and patch things until tests pass, without a deeper understanding of why.
14
1
61
Feels like another variant, of Goodhart's law. Unit tests become our success metric, and human nature being what it is we then optimize to that metric. As opposed to some abstract 'code quality'. en.wikipedia.org/wiki/Goodha…
1
4
I feel like this would happen without the unit tests in place, though, right? The reporting case essentially becomes a unit test (regression test) when it is confirmed that it represents a bug, and ppl who would flail around at unit tests will just flail around at the reprex...
1
and have much less coverage to prevent regressions as they do, in the absence of other unit tests...
1
At that level of fatalism, _nothing_ will ever beat #RStatst `fortunes:: fortune("theorem")` /cc @dmbates
1
1
I don't mean its inevitable in all cases, was just saying I'm skeptical that even in the "lazy in the face of unit tests" case (which I agree are real), that anything would be actualy better without them, because in situations like that I suspect the behavior will happen anyway
1
Unit tests are great, things are much better with them
1
2
They certainly changed how we write, test and release code. While imperfect they moved the needle. A lot.

Nov 12, 2021 · 2:00 AM UTC

1
2
I agree, I am extremely pro unit tests. because if you're going to fix bugs lazily, they make it safer, and they don't prevent you from fixing bugs right :)
1