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

In reply to Re: How does one avoid tautologies in testing? by gwadej
in thread How does one avoid tautologies in testing? by ELISHEVA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.