NAME
Test::Builder2::Module - Write a test module
SYNOPSIS
use Test::Builder2::Module;
our @EXPORT = qw(is);
# is( $have, $want, $name );
install_test( is => sub ($$;$) {
my($have, $want, $name) = @_;
my $result = $Builder->ok($have eq $want, $name);
$result->diagnostic([
have => $have,
want => $want
]);
return $result;
});
DESCRIPTION
A module to declare test functions to make writing a test library easier.
FUNCTIONS
install_test
install_test( $name => $code );
Declares a new test function (aka an "assert") or method. Similar to writing sub name { ... }
with two differences.
1. Declaring the test in this manner enables the assert_start and assert_end hooks, such as aborting the test on failure. 2. It takes care of displaying the test result for you. 3. The $Builder object is available inside your $code which is just a shortcut for $class->builder
The prototype of the $code is honored.
$code must return a single Test::Builder2::Result::Base object, usually the result from Test::Builder2->ok()
or any other test function.
METHODS
builder
my $builder = Your::Test->builder;
Your::Test->builder($builder);
Gets/sets the Test::Builder2 for Your::Test. Also changes $Builder
for Your::Test.