Some time ago I had a discussion with my colleague. I was trying to explain why test doubles should be used to isolate unit under test.
He used an argument I couldn’t respond to:
Using mocks reduces code coverage of tests.
It’s true, but here’s the thing:
Code coverage does not bring value in itself.
Isolated tests brings value, because they can be used to pinpoint errors (and be used as code documentation and usage examples)
Fast tests are valuable – because slow tests are disincentive to use them constantly.
Code coverage is just a quantity indicator. But just from code coverage one can tell nothing about quality. And additionally code coverage – which you loose when using test doubles – is indirect code tests and is a code smell that you may have hidden dependencies.