Test::Builder - Backend for building test libraries
package My::Test::Module;
use base 'Test::Builder::Module';
my $CLASS = __PACKAGE__;
sub ok {
my($test, $name) = @_;
my $tb = $CLASS->builder;
$tb->ok($test, $name);
}
Test::Simple and Test::More have proven to be popular testing modules, but they're not always flexible enough. Test::Builder provides a building block upon which to write your own test libraries which can work together.
my $Test = Test::Builder->new;
Returns a Test::Builder object representing the current state of the test.
Since you only run one test per program new
always returns the same Test::Builder object. No matter how many times you call new()
, you're getting the same object. This is called a singleton. This is done so that multiple modules share such global information as the test counter and where test output is going.
If you want a completely new Test::Builder object different from the singleton, use create
.