http://www.perlmonks.org?node_id=780397


in reply to How does one avoid tautologies in testing?

It's important to keep in mind that unit testing often serves multiple purposes. Partially, the tests serve to understand and validate the code. They also help document usage. They (hopefully) also get used for regression testing. I find tautological tests (let's call them Ttests) are most useful in this final case.

moritz hits the nail on the head with the comments about the Perl 6 testing. The purpose of these simple Ttests is to make sure something fundamental has not changed. If (after your tests have been in use for a while) one of these Ttests fails, you know immediately that something fundamental in the system has been broken.

For example, will this test save you someday when someone decides that some caching or lazy-loading solution can be added because it could not possibly break anything.

Some of the longest debugging sessions I've ever been part of were finally resolved when we tested something that could not possibly be wrong and it was. Every time I put in a Ttest, I think about these sessions. Every now and then, I catch a bug this way.

G. Wade
  • Comment on Re: How does one avoid tautologies in testing?