Instead of running the creating a run_tests.pl
to run the test suite, the standard practice is to use prove
.
Say you have
t/foo.t
t/bar.t
Then,
prove
is short for prove t
.
prove t
runs the entire test suite (both t/foo.t
and t/bar.t
).
prove t/foo.t
runs that specific test file.
perl t/foo.t
runs that specific test file, and you get the raw output. Easier for debugging.
perl -d t/foo.t
even allows you to run the test in the debugger.
Each file is a self-standing program. If you need to share code between test programs, you can create t/lib/Test/Utils.pm
(or whatever) and use the following in your test files:
use FindBin qw( $RealBin );
use lib "$RealBin/lib";
use Test::Utils;
prove
executes the files in alphabetical order, so it's common to name the files
00_baseline.t
01_basic_tests.t
02_more_basic_tests.t
03_advanced_tests.t
The 00
test tests if the modules can be loaded and that's it. It usually outputs the versions of loaded modules to help with dependency problems. Then you have your more basic tests. The stuff that's like "if this doesn't work, you have major problems". There's no point in testing the more complex features if the basics don't work.