A test should be a help, not a hinder

A test is meant to help you. If it does not help you, something is wrong.

There are many ways in which a test can be a hinder rather than a help. It can be tightly coupled with the implementation, making the code harder to work with. It can be long, complex and very hard to read. It can execute some code without actually validating anything, giving a false sense of security.

If you find yourself having a unhelpful test on your hand, I would recommend taking one of the following steps, in this order.

  1. Understand it. Make sure that the problem lies with the test, and not your understanding.
  2. Fix it. If you do understand it, and realize that it is a badly written test – fix it!
  3. Delete it. As a last resort, if fixing the test is not worth the cost, the test should be deleted!

Positive Return On Investment

To put it another way, we can borrow some terminology from economy: a test should have a positive Return On Investment (ROI). That means as follows.

The value you get out of a test should be higher than the cost to write and maintain it.

If this is not the case, the test needs to be fixed or deleted.

Keeping a bad test just because “it’s already written” is a dangerous road to take. Tests still cost money to maintain. If it is in a part of the code that isn’t changed anymore, fine, keep it. If it tests code that is under development, then do something about it.

One thought on “A test should be a help, not a hinder

  1. We are actually will quickly and properly create a service warranty Premium remodelling manhattan. Tonya Rafi Hamer

Leave a Reply

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