The only reason not to, as far as I can divine, is the worry that your tests might stop part way through without producing a non-zero exit code.

It can also be a useful sanity check when you know the number of tests. For example they're useful when you accidentally cut and forget to paste, or when you have test runs where you have the number of tests determined at runtime and a dodgy piece of logic.

I do think the file is the wrong level of granularity though, which is why I tend to have them at the method level (via Test::Class) or block level (via Test::Block) if I do use them.

Overriding exit() sounds like the better choice. Sticking something at the end of the script could cause problems with test scripts the have multiple or non-obvious exit points. You'd have to be careful about thinks like Test::Builder's skip_all.

The only other things that I can think of that would exit cleanly would be POSIX::_exit or a piece of XS code. However AFAIK neither of those would run the Test::Builder END block so Test::Harness would pick up on the lack of a test footer.

That said I'd just not sweat it, use no_plan, and not worry.


In reply to Re: How can I write Test::Finished? by adrianh
in thread How can I write Test::Finished? by samtregar

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.