Test::Builder - Backend for building test libraries
module My::Test::Module; use Test::Builder; use Test::Builder::Output; my Test::Builder $Test .= new( output => Test::Builder::Output.new( error_output => open('my_error_log_file') ) ); sub plan (Str $explanation?, Int $tests?) is export { $Test.testplan($explanation, $tests); } sub ok ($passed, $description?, $todo?) is export { if $todo { $Test.todo($passed, $description, $todo) || $Test.diag("FAILED : $description"); } else { $Test.ok($passed, $description) || $Test.diag("FAILED : $description"); } } sub is ($got, $expected, $description?, $todo?) is export { if $todo { $Test.todo($got eq $expected, $description, $todo) || $Test.diag("FAILED : $description"); } else { $Test.ok($got eq $expected, $description) || $Test.diag("FAILED : $description"); } } # then using our test module the test file themselves ... use My::Test::Module; plan('no_plan'); # or plan :tests<20>; ok(2 == 2, '... 2 is equal to 2'); is(2 + 2, 5, '... 2 plus 2 should be 5', :todo<bug>);
This is a Perl 6 port of the Perl 5 module Test::Builder.
This method actually returns a Test::Builder singleton, creating it if necessary. The optional named arguments are:
output
A Test::Builder::Output object.
plan
A Test::Builder::TestPlan object.
This method actually creates and returns a new Test::Builder instance. It takes the same optional named arguments as new.
new
Sets the current test plan or throws an exception if there's already a plan in place. You have two options for the plan. If you pass a pair such as tests =Egt 10, the plan is to run ten tests. If you pass the string no_plan, there is no set number of tests to run.
tests =Egt 10
no_plan
Those are the only valid arguments.
You must have a plan set before you can record any tests.
Records that a test has passed or failed, depending on the value of $passed, recording $description as an optional explanation.
$passed
$description
Records that a test has passed or failed, depending on $passed with an optional $description, but marks it as a TODO test with an optional $reason.
$reason
Records the skipping of $num tests (one by default), giving an optional $reason for skipping them.
$num
Skips all of the tests before running them.
Fails if there is a test plan set.
Aborts the entire test run.
Returns the number of the next test to record.
Records a test. Internal use only, probably.
Perl 5 Test::Builder.
code by chromatic <chromatic@wgz.org>
documentation by Stevan Little <stevan@iinteractive.com> and chromatic.
To install Perl6::Pugs, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl6::Pugs
CPAN shell
perl -MCPAN -e shell install Perl6::Pugs
For more information on module installation, please visit the detailed CPAN module installation guide.