Exhaustive Unit Testing
roy at panix.com
Thu Nov 27 15:54:21 CET 2008
In article <492ea611$0$32680$9b4e6d93 at newsspool2.arcor-online.net>,
Stefan Behnel <stefan_ml at behnel.de> wrote:
> Not to mention that you can sometimes look at awfully trivial code three
> times and only see the obvious bug in that code the fourth time you put an
> eye on it a good night's sleep later.
Or never see it.
Lately, I've been using Coverity (static code analysis tool) on a large C++
project. I'm constantly amazed at the stuff it finds which is *so* obvious
after it's pointed out, that I just never saw before.
> Expecting code paths in a nested if statement with nine conditions that are
> not worth testing due to obvious triviality, is pretty hubristic.
There's a well known theory in studies of the human brain which says people
are capable of processing about 7 +/- 2 pieces of information at once.
With much handwaving, that could be applied to testing by saying most
people can think through 2 conditionals (4 paths), but it's pushing it when
you get to 3 conditionals (8 paths), and once you get to 4 or more, it's
probably hopeless to expect somebody to be able to fully understand all the
possible code paths.
More information about the Python-list