Python from Wise Guy's Viewpoint

Marshall Spight mspight at dnai.com
Fri Oct 24 16:43:39 EDT 2003


"Joachim Durchholz" <joachim.durchholz at web.de> wrote in message news:bn8etq$e8o$1 at news.oberberg.net...
>
> A test suite can never catch all permutations of data that may occur (on
> a modern processor, you can't even check the increment-by-one operation
> with that, the universe will end before the CPU has counted even half of
> the full range).

Just to be pedantic, there are some circumstances where this is
possible. For example, it is quite possible to construct a test suite
that will exhaustively test the boolean "or" operator. There are
exactly four test cases, so that's not too bad.

It's worth mentioning this because it points out what you
have to do for a unit test suite to provide the degree of
coverage that any theorem-proving based system does:
you have to check the entire set of inputs for the function.
Sometimes I run into unit test boosters who feel that
they're provably correct when they have a test case
for every code path. But you'd have every code path
tested with just one test case for the "or" example,
whereas you need fully 4 test cases before you're
provably correct.

Hmmm. Should my test suite for "or" include
passing it strings and ints and checking to be
sure it gives an exception?


Marshall






More information about the Python-list mailing list