"Is it not bad practice to force the user to install a module just for the tests?"

Not necessarily.

In general, I'd expect the user to run `make test` (perhaps via cpan or other, similar utility). My Makefile.PL files typically include:

'Test::More' => 0,

Do note that if you're using features from later versions, you should adjust the minimum version accordingly; for instance, if you use done_testing(), you'll need:

'Test::More' => 0.88,

The end-user is not expected to run Author Tests. These usually require $ENV{RELEASE_TESTING} (or similar) to have a TRUE value. I don't know what you're using at the moment, but I believe I've seen Test::Pod and Test::Pod::Coverage (maybe others).

My current practice is to list the modules needed for Author Tests in the README file; although, that's a fairly recent thing and I'm still evaluating whether to continue with it. However, I also supply a safety net. Here's one of my test files (specifically for personal use):

$ cat 99-00_pod.t #!perl use v5.36; use Test::More; BEGIN { if (! $ENV{CPAN_AUTHOR_TEST}) { plan skip_all => 'Author test: $ENV{CPAN_AUTHOR_TEST} false.'; } } eval { use Test::Pod 1.52; 1; } or do { plan skip_all => 'Test::Pod 1.52 required.'; }; all_pod_files_ok();

Skipping means that tests don't fail but do report what test module was missing. I only recommend this for Author Tests.

You're welcome to use that. You'd need to make some adjustments around version numbers. Also, I use RELEASE_TESTING for $work; CPAN_AUTHOR_TEST, in my personal code, avoids conflicts.

— Ken


In reply to Re^5: STDERR in Test Results by kcott
in thread STDERR in Test Results by Bod

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.