in reply to Re^4: Self-testing modules
in thread Self-testing modules
See Test::LectroTest for the only cpan test module (I consider) worthy of the Test:: prefix.
Simplified rational:
Most bug arise as a result of the programmer making assumptions. If the same programmer writes the tests for the code s/he wrote, they will make the same assumptions. The net result is they write tests for every case they considered when writing the code, which all pass--giving them N of N tests (100%) passed and a hugely false sense of security.
The cases they fail to tests for, are the same cases they failed to consider when writing the code, and those are normally the same cases that crop up immediately they demo it or put it into production.
With anything other than the most trivial of functions, hoping to test all possible combinations of inputs and verify those outputs is forlorn. Ie. impossible for any practical sense of the term.
Therefore, the only way to test code is to test is complience against a (rigourous) specification, and derive security through statistics. Ideally, this would go one step further than LectroTest and retain a record of failing values and these would be reused (along with a new batch of randomly generated ones) at each subsequent test cycle. (IMO) this is the only way that testing will be lifted out of it's finger-to-the-wind, guesswork state and move into something approaching a science.
LectroTest isn't perfect (yet). It has fallen into the trap of becoming "expectation complient" in as much as it plays the Test::Harness game of supplying lots of warm-fuzzies in the form of ok()s, and perpectuating the anomoly of reporting 99.73% passed instead of 0.27 "failed", or better still:
***FAIL*** Line nnn of xxxxxx.pl failed running function( 1, 2, 3 ); Testing halted.
Preferably dropping the programmer into the debugger at the point of failure. Even more preferably, in such a way that the program can be back-stepped to the point of invocation and single stepped through the code with the failing parameters in-place so that the failure can be followed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Self-testing modules
by adrianh (Chancellor) on Jul 30, 2005 at 14:43 UTC | |
by tlm (Prior) on Jul 31, 2005 at 20:45 UTC | |
by adrianh (Chancellor) on Aug 01, 2005 at 10:57 UTC | |
by tlm (Prior) on Aug 02, 2005 at 02:48 UTC |