"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.
|