Test::Builder2::Module - Write a test module
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; });
A module to declare test functions to make writing a test library easier.
install_test( $name => $code );
Declares a new test function (aka an "assert") or method. Similar to writing sub name { ... } with two differences.
sub name { ... }
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
$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.
Test::Builder2->ok()
my $builder = Your::Test->builder; Your::Test->builder($builder);
Gets/sets the Test::Builder2 for Your::Test. Also changes $Builder for Your::Test.
$Builder
To install Test::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Simple
CPAN shell
perl -MCPAN -e shell install Test::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.