Friday, July 16, 2010

The way of testing

Even if you're not a software developer, you know what a software bug is. If you've ever wondered why those bugs made it into the finished product, here's a blog post that can tell you how they could have avoided them. And if you are a software developer, then here's some good advice.

Testivus, Testability and Dr. Jekyll and Mr. Hyde

Somewhat ironically, the blog post was originally published with the title Dr. Jekill and Mr. Hide, which proves that editing of blog posts is as important as testing of code.

While overall, I think this has some good advice, I strongly disagree with one part: The maxim "Think of the code and test as one" is a path to disaster. This leads to people doing things like sharing code between production code and test code and writing the same bugs into the tests that the production code has. Yes, tests themselves can have bugs.

Here's some advice that I think is better:

Think of code and test as two sides of a coin

You can't have a coin with just one side.
When writing the code, think of the test.
When writing the test, think of the code.

A coin with two heads is designed to cheat.
Don't copy from the code to the test.
Don't copy from the test to the code.

Search This Blog