Everything I don’t like about unit testing

…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.

The alternative:

Writing high-level tests that are driven by user behavior will provide you with much higher return on investment in the long run

Amen.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s