As chromatic says, if I'm testing a single, small module, I usually just use a single .t file. I would rename 00-load.t to 00-Foo_Bar.t and put all my tests in it.

If it's multi-module or just complex, I break up the test files by related functionality. Since I tend to favor test-driven development, I find that I create a new test file for each new feature I implement. As soon as I'm "done" with a feature and on to the next, I create a new test file.

Breaking it up like this means that I'm usually only running the tests for the current feature under development, which keeps the testing time down. Then periodically, I run the full test suite to make sure I didn't break anything else in the process.

Often, I find that some tests wind up being a loop over a bunch of test data in a datastructure. (See Re^2: Wanted, more simple tutorials on testing for an example of this.) I that case, I usually make a separate .t file for each datastructure.

As a side note, if I'm thinking of distributing this to CPAN, I also make the boilerplate pod.t and pod-coverage.t optional by adding something like this at the top:

use Test::More; plan skip_all => "Skipping author tests" if not $ENV{AUTHOR_TESTING};

Not everyone agrees with this approach, but that's how I do it.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.


In reply to Re: How do folks organize unit tests? by xdg
in thread How do folks organize unit tests? by hesco

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.