|parrotcode: Parrot extension for building test modules|
|Contents | Libraries|
Test::Builder - Parrot extension for building test modules
# load this library load_bytecode 'library/Test/Builder.pir' # create a new Test::Builder object .local pmc test .local int test_type find_type test_type, 'Test::Builder' test = new test_type # plan to run ten tests test.'plan'( 10 ) test.'ok'( 1, 'some test description' ) test.'ok'( 0, 'some test description' ) test.'diag'( 'the last test failed on purpose!' ) test.'skip'( 3, 'do not run these three tests' ) test.'todo'( 1, 'this is a todo test that passes', 'i am not sure' ) test.'todo'( 0, 'this is a todo test that fails', ' i am still not sure' ) test.'skip'( 4, 'cannot think of four more tests' ) # you must call this when you have finished! test.'finish'()
Test::Builder is a pure-Parrot library for building test modules. It manages test plans, formats and reports test results correctly, and has methods to manage passing, failing, skip, and TODO tests. It provides a simple, single backend for multiple test modules to use within your tests.
This class defines the following methods:
new( args_hash )
Hashof arguments, initializes the new object with the provided arguments. By default, you should rarely need to pass any arguments. If you do, you know why. The two allowed arguments are:
Test::Builder::TestPlanto manage the plan for this test run.
Test::Builder::Outputto manage the output for this test run.
new()will not always return the same object, but every object will share the same state.
create( args_hash )
plan( number_or_no_plan )
no_plan. This will throw an exception if you have already declared a plan or if you pass an invalid argument.
diag( diagnostic_message )
ok( passed, description )
passed, recording it with the optional test description in
todo( passed, description, reason )
passed, but marks it as TODO so it always appears as a success. This also records the optional
descriptionof the test and the
reasonyou have marked it as TODO.
skip( number reason )
numberof tests as skip tests, using the optional
reasonto mark why you've skipped them.
exit; there's little point in continuing.
BAILOUT( reason )
reasonas explanation. This also calls
Written and maintained by chromatic,
chromatic at wgz dot org, based on the Perl 6 port he wrote, based on the original Perl 5 version he wrote with ideas from Michael G. Schwern. Please send patches, feedback, and suggestions to the Perl 6 internals mailing list.
Copyright (c) 2005, the Perl Foundation.