…brilliantly summed up by Alexey Golub in “Unit Testing is Overrated”.
My main complaint is that they greatly expand the complexity of the code with interfaces and abstractions that only exist for the sake of the unit tests, without actually testing the application the way it will be used. Users don’t care how high your code coverage is if the app doesn’t work.
He comes out swinging right after the bell:
Focusing on unit tests is, in most cases, a complete waste of time.
Kinder, gentler version:
If you treat unit testing as a goal in itself, you will quickly find that, despite putting a lot of effort, most tests will not be able to provide you with the confidence you need, simply because they’re testing the wrong thing. In many cases it’s much more beneficial to test wider interactions with integration tests, rather than focusing specifically on unit tests.
Writing high-level tests that are driven by user behavior will provide you with much higher return on investment in the long run