TDD and the Magic Buttons

Listen to this post
Subscribe

Here is a bit of a thought experiment, first suggested to me by Eran Pe’er.

Imagine there are two magic buttons in front of you. You know, without any doubt that if you press Button A then your code will suddenly have 90% code coverage. If you push Button B, you will have 80% code coverage.

But there is another difference.

  • If you press Button A, only 10% of your code will be uncovered by tests. But you will have no idea where that 10% in the system.
  • If you press Button B, 20% of your code will be uncovered by tests. In this case, however, you will know exactly where that uncovered code is.

Which would you press? If your answer is B, which is what most people choose, it tells you about your true attitude towards risk. We eliminate all we can, but once we have done that it is more important to know where the remaining risks are than to eliminate a few more of them blindly.

What coverage really means, and how we achieve it in TDD, is all about this.

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.