4 ms·
The thing that drives me nuts about these threads is that people vastly overestimate their ability to write code that isn't broken. I distrust myself, and ther
by rectang 2y ago
The thing that drives me nuts about these threads is that people vastly overestimate their ability to write code that isn't broken. I distrust myself, and therefore I write basic unit tests which validate the code I've written to prove that I haven't screwed up.
Such unit tests are quick to write and don't change frequently because they run against low-level building blocks — so they are not a major maintenance burden. The ROI on this kind of testing is very high.
I don't like being told by Dodds and these other unit-test haters that I shouldn't be doing this. In my experience, organizations suffer much more when developers eschew such tests, being quite naturally overly optimistic about the reliability of their work.
Writing low-level unit tests doesn't prevent you from writing integration or end-to-end tests, and those are important too. I'm not here to devalue higher-level testing, and I'd appreciate it if advocates for higher-level testing likewise didn't go out of their way to devalue unit tests.
- bluefirebrand 2y ago> I distrust myself, and therefore I write basic unit tests which validate the code I've written to prove that I haven't screwed up. This drives me nuts. You don't trust yourself to write code that isn't broken but you trust yourself to write quality tests that ensure the code isn't broken? I don't understand this at all. Automated tests are just like any code, they are as prone to mistakes and bugs as anything else
- rectang 2y agoMy tests might of course be faulty, but statistically speaking adding some will reduce the number of bugs in the main code that get through. The tests don’t have to be perfect to have a positive impact; in fact my impression is that the lowest-effort tests have an outsized impact and a very high ROI.