Authors of Test modules, listen up.
I've never quite properly described the purpose of Test::Builder.
Mostly its come off as a way to tweak Test::More's behavior a little
or to implement your own Test::More-ish library.
It does that, but that's not what's really neat. And I only just
realized this talking to Barrie.
Test::Builder lets you use *multiple* Test modules in a *single* test
program!
Its a solution to the age-old problem of "Gee, I'd love to use this
one function from Test::Special::Purpose, but I need all the stuff
from Test::More, too."
If Test::Special::Purpose were built using Test::Builder then both
Test::More and Test::Special::Purpose share the same Test::Builder
object. This means the test counter is kept in sync between the two.
use Test::More tests => 3;
use Test::Special::Purpose qw(defuse_camel_ok);
# from Test::More. Increments the Test::Builder counter to 1
use_ok('Kamikaze::Camel');
my $camel = Kamikaze::Camel->ATTACK;
# also from Test::More. Increments the counter to 2
isa_ok( $camel, 'Kamikaze::Camel' );
# from Test::Special::Purpose. Uses the same Test::Builder object
# as Test::More, so it increments to 3
defuse_camel_ok( $camel, 'whew' );
Ta da! No longer need there be a single, canonical Test module, just
a single, canonical backend. So you can pick and choose with more
freedom what modules are right for your tests.
Candidates for this sort of thing would be CGI::Test, Test::Cmd,
Test::Unit, Test::Mail and ExtUtils::TBone. And, of course, Barrie's
Test::Differences.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
Carpe canem! Seize the dog! This cannot be right.
-- The Critic