3 ms·
This is comically bad. Way too long and myopic but the points aren’t even useful points. > “ unit tests are only useful to verify pure business logic inside of
by mlthoughts2018 6y ago
This is comically bad. Way too long and myopic but the points aren’t even useful points.
> “ unit tests are only useful to verify pure business logic inside of a given function.”
Yep, that’s one of the most important things you need to verify. You should also verify integration test success, and then the unit test allows you to immediately observe where is the failure: is it pure business logic failure when all external factors were mocked? Or is it integration failure? Or is your dependency flaky & untrustworthy?
Without unit tests you can’t (a) develop business logic in isolation from the external resources it will integrate with or (b) easily isolate what is a business logic error vs what is an integration error.
It’s just so dumb to use language like saying unit tests “are only useful” for this. That’s a hugely valuable thing to be useful for!
> “ no practical purpose other than making unit testing possible.“
This is incredibly bad circular reasoning. You must first already agree that unit tests confer no value, only then is this considered a point by the author. But if unit tests do add value (and they really do) then refactoring to facilitate unit tests also adds value!
The point about testing a hidden implementation is mixed. On one hand the example used here is just a bad example. On the other hand, testing a hidden implementation can be a very good thing because it assists the act of development in the first place. The test helps the person writing the business logic to write, by factoring into a test that's proof of correctness. Maybe it’s debatable that it should be removed like scaffolding when they are done if it’s a hidden implementation, but that’s really a local decision for a team to make. Sometimes it’s good leave those tests of hidden implementations because they add extra protection for changes that can have unintended consequences.
> “unit tests are expensive”
yawn.