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?

Comments (1)

  1. Keith Farmer says:

    I’ve considered the same, but the immediate question is where does the chain of testing end?

    I think, given the circumstance, that it’s much easier to prove a test than it is to prove the code the test is testing.  That’s why we have unit tests.  As long as you keep the tests as small, consistent, and straightforward as possible, there’s no need to test the tests.

    That doesn’t mean there’s no need to consider the completeness of the tests, and whether they fail when the prerequisites are not satisfied.  It merely means that formally unit testing the tests just adds another set of tests to test.

Skip to main content