Unit Testing and Testers
Don’t think for a second that I’m going to recommend that testers write unit tests for someone else’s code. Everyone knows that unit tests are best written by the author of the code – a point which I agree with 100%. Instead, I want to ask a question about unit testing test code.
If you are a tester who writes automated tests or test tools, do you write unit tests? You better be (ed. Stronger language deleted). In fact, I can’t think of any reason why anyone calling themselves a tester wouldn’t write unit tests for their test code. I’m betting no one is testing it, and I bet you’re just as capable of creating defects as anyone. So why not give yourself a shot at writing effective test cases with as few false positives (or worse – true negatives) as possible (I think I made up the term “true negatives.” I wanted a title similar to “false positive” to denote the case where a bug in a test causes it to pass even though a bug exists).
In fact, I think TDD is highly suitable for test code. Can anybody think of an argument to the contrary, or am I just stating the obvious?