2 ms·
Sounds like a lot of projects you worked on had tests at the wrong granularity. Fine grained unit tests are good for helping you find out where a bug is in the
by munificent 11y ago
Sounds like a lot of projects you worked on had tests at the wrong granularity.
Fine grained unit tests are good for helping you find out where a bug is in the code, at the expense of calcifying your architecture. "Functional", "integration", "end-to-end" or other higher level tests don't pinpoint a bug as easily but in return they give you greater freedom to reorganize your implementation.
For example, I work on a code formatter:
https://github.com/dart-lang/dart_style https://github.com/dart-lang/dart_style
It has a metric ton of tests, which is absolutely critical for ensuring a change to one corner of the formatting doesn't regress other things. Formatting is solving a bunch of global constraints, so almost every change interacts with other things.
I've rewritten almost the whole thing twice at this point, and the tests never slowed me down. That's because they're functional tests: they just run the formatter and validate the expected output.
It does mean I spent a hell of a lot more time figuring out why some test was failing, but it made refactoring a joy.