Isolated Unit Tests and Fine Grained Failures

Posted by Winston Ewert on Programmers See other posts from Programmers or by Winston Ewert
Published on 2014-08-23T17:21:15Z Indexed on 2014/08/23 22:33 UTC
Read the original article Hit count: 290

Filed under:
|

One of the reasons often given to write unit tests which mock out all dependencies and are thus completely isolated is to ensure that when a bug exists, only the unit tests for that bug will fail. (Obviously, an integration tests may fail as well). That way you can readily determine where the bug is.

But I don't understand why this is a useful property. If my code were undergoing spontaneous failures, I could see why its useful to readily identify the failure point. But if I have a failing test its either because I just wrote the test or because I just modified the code under test. In either case, I already know which unit contains a bug.

What is the useful in ensuring that a test only fails due to bugs in the unit under test? I don't see how it gives me any more precision in identifying the bug than I already had.

© Programmers or respective owner

Related posts about unit-testing

Related posts about TDD