Bad Tests vs. No Tests vs. Never Tests

Bad tests are worse than no tests. But never trying to test is far, far worse than writing bad tests.

Bad tests will exert a friction on your development efforts. They cost time to write, they cost time to maintain, they don’t provide clear benefit, and they may even guide you to bad design choices. Under the desperate pressure of a rock-and-a-hard-place deadline situation, if you don’t know how to write good tests it’s often better to just not write them. You’re naturally going to have more churn in the code, and removing the burden of testing may actually make the churn less disruptive and the code more stable.

Sidebar: “The desperate pressure of a rock-and-a-hard-place deadline situation” is a place you don’t want to be. It very rapidly becomes an “unsustainable no-win situation.” In the long term, the only way to win is not to play. In the short term, you do what you can to get by until it’s over, and hope you’ll be allowed clear the mess before moving on.

The key to Test Driven Design is that good tests drive good design. Bad tests don’t… in the short term. Bad tests must be suffered, and examined, then removed, and rewritten. Bad tests must be improved through iteration, in tandem with the code that they test. Bad tests are learning tools to help you write good tests, which help you write better code. But if you don’t have the time necessary to reflect, iterate, and learn from your tests, all you’ll get from them is a creeping bitrot and a demoralizing stink.

The moral of this story is not that you shouldn’t test. It is to recognize that tests are not inherently good. They are a tool with a particular purpose, and they must be used properly and given room to do their job. If you can’t give them the room they need, then they’re not the right tool for your situation.

Yeah, that’s a situation that you wouldn’t have in an ideal world. Maybe you should say something about it. Maybe you should find a new job. Or maybe it’s just a tight spot and you need to fight through it. But for goodness sake, don’t make a bad situation worse by imposing a burdensome constraint that you can’t benefit from.