TB2::Module - Write a test module
use TB2::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->diag([ 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 Test::Builder2->default.
Builder
Test::Builder2->default
The prototype of the $code is honored.
$code must return a single TB2::Result::Base object, usually the result from Test::Builder2->ok() or any other test function.
Test::Builder2->ok()
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.