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 )
Hash
of 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:testplan
does
Test::Builder::TestPlan
to manage the plan for this test run.output
Test::Builder::Output
to 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 )
finish()
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 description
.todo( passed, description, reason )
passed
, but marks it as TODO so it always appears as a success. This also records the optional description
of the test and the reason
you have marked it as TODO.skip( number reason )
number
of tests as skip tests, using the optional reason
to mark why you've skipped them.skip_all()
exit
; there's little point in continuing.BAILOUT( reason )
reason
as explanation. This also calls exit
.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-2007, The Perl Foundation.
|