Full statement coverage

When I read Ron Jeffries Soduko articles, I was wondering why he was writing such sloppy unit tests. He didn’t seem to test even half of the code he wrote. A short email conversation later I had realized that he of course wasn’t sloppy, but rather just much more clever than I was (not that surprising, really). ;-)

If a test exercises method a() which in turn calls b(), then both a() and b() are in fact tested. If b() is changed (in an incorrect way) there is a test which will fail. In other words, he was writing the least amount of test code necessary to get full statement coverage. Pretty smart, if you ask me.

I guess there is nothing wrong in doing extensive testing, besides perhaps that the development moves forward more slowly (at least in a short perspective). TDDers like to say, test until fear turns to boredom. So apparently I wasn’t bored enough by writing the tests yet.

There are no comments on this post

Leave a Reply