This question is related to this question I asked before. I have multiple test files (A.t, B.t, C.t etc) created to test their respective module A, B, C & so on. But when I
Executing tests directly through perl
works. The prove
command was designed to simplify the process, save keystrokes, and shorten the test-debug-test cycle.
prove
was designed to work on multiple tests at a time, which you can't do invoking via perl
. For instance, you can do:
prove t/*.t
prove t/ # Same as t/*.t
prove t/dev/ # Run only tests in t/dev/
prove -r t/ # Runs all .t files in t/ and any directories below.
The modern prove
also has many features for handling suites of tests and modifying how the TAP output from the tests is displayed.
prove --help
will show you all prove
's options, and prove --man
will show you the manual page.
I just run the test that I want to run:
% make; perl -Mblib t/B.t
You can do the same thing with prove
, too.
That -Mblib
loads the module blib which merely adds blib/lib (and various special directories under it) to @INC
for you. It comes with Perl. prove
should do the same thing with the -b
switch.
My command is really two parts: the make
(or ./Build
for Module::Build. This builds the source and moves Perl modules and other files into the "build library", or blib, as an intermediate step in the full installation. Normally make test
works against the versions in blib and refreshes that for me. Since I'm testing on my own, I ensure that I refresh blib myself and include it in Perl's module search path.
Despite the fact that I know all this, you might be surprised that I often forget to do one of those steps and end up testing against the wrong version of things, whether the fully installed old version (forgot -Mblib
) or the old development sources (forgot make
). This leads me to debugging statements such as:
print "No really, this is the Foo version. kthnxbye\n";