TDD “Good” Tests Part 1. The test must reliably fail for the reason intended

TDD requires an expenditure of developer effort. All such effort is an investment, and thus should yield a return. TDD returns value in many ways, but here I will focus on one way in particular:

Tests prove their worth when they fail.

When a test fails, this is the point when we say “wow, we’re glad we wrote that test” because otherwise there would be a defect in the system that was undetected. But we can also ask how *much* value a test’s failure provides, and the answer is that the value is relative to the quality of the information it provides in that failure.

When a test fails for the reason it was intended to, this means several things:

  1. That intention was clearly understood when the test was written.
  2. That intention is clearly documented because of the way the test was written.
  3. The exact nature and location of the defect is made extremely clear.

Most developers will tell you that the tricky thing about debugging is not fixing the bug, but rather finding what and where it is in the code. Test that fail reliably for the reason they were intended to fail make the “find” much easier, and therefore reduce the cost of maintenance.

This is Scott Bain. Visit us at

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.