4 ms·
I commonly hear this, and yet it is so wrong. I don't understand how this idea that unit tests significantly protect against regressions has spread so far. Clas
by jcrben 10y ago
I commonly hear this, and yet it is so wrong. I don't understand how this idea that unit tests significantly protect against regressions has spread so far. Classic texts such as "Growing Object-oriented software with Tests" note, rightly, that end-to-end tests are for external reliability.
Unit tests, which don't operate on that abstract high level, give you relatively little safety. Sometimes they can ensure that an algorithm is not broken, but algorithms is usually not where the legacy code has issues. Often unit tests are at the level of "assert that X function calls Y stub Z times".
- atilaneves 10y ago> "assert that X function calls Y stub Z times" That's a terrible test that should never pass code review. It's worse than no test at all - it's brittle and guarantees nothing. Writing good tests is _hard_.
- struppi 10y agoI totally agree with you. In the end you need different kinds of tests (end-to-end, unit, ...). And with legacy code, you probably want to start with end-to-end tests or integrated tests. But in that specific case, no amount of tests would have helped us...