Mainly a note for my own later usage...
Test-driven development is great, but it comes with the overhead of all the prerequisites required by the testing libraries. So you may wish not to run all of your tests by default when the end-user installs your module.
Pete Sergeant (sheriff on IRC) suggests using an environment variable for doing this:
plan skip_all => 'set DEVELOPER_TESTS to enable these tests' unless $ENV{DEVELOPER_TESTS};
Claes suggested:
eval "use Test::Something::VeryDetailed"; plan skip_all => "..." if $@;
So I would probably merge the two.
if ($ENV{DEVELOPER_TESTS}) {
eval "use Test::Pod::Coverage";
plan skip_all => "..." if $@;
} else {
plan skip_all => 'set DEVELOPER_TESTS to enable these tests'
}
This way you could save having to include all the developer testing modules in the Makefile.PL.
$ENV{AUTOMATED_TESTING}
is in common use to help tests change behavior when being run by a smoke testing system.
I've seen (and have adopted myself) the use of $ENV{AUTHOR_TESTING}
for the purpose you describe.
$ENV{ TEST_AUTHOR } and eval q{
use Test::Pod::Coverage;
goto RUN_TESTS;
};
plan skip_all => $@
? 'Test::Pod::Coverage not installed; skipping POD coverage'
: 'Set TEST_AUTHOR in your environment to enable these tests';
RUN_TESTS:
GOTO
is sometimes the only way to express control flow consisely.
Re:When existing control structures are insufficie
hex on 2007-06-25T15:29:39
Swish!
use strict;
use inc::Module::Install;
name 'Foo';
all_from 'lib/Foo.pm';
requires 'File::Spec' => 0;
build_requires 'Test::More' => 0;
# Developer and automated testing
if ( $ENV{AUTOMATED_TESTING} ) {
build_requires 'Test::Pod' => 0;
build_requires 'Test::Pod::Coverage' => 0;
}
WriteAll;