![]() |
![]()
| ![]() |
![]()
NAMEBadger::Test::Manager - test manager module SYNOPSISuse Badger::Test::Manager; # object methods my $manager = Badger::Test::Manager->new( plan => 7 ); $manager->ok($bool, 'This is a test'); $manager->pass('This is ok'); $manager->fail('This is not ok'); $manager->is($this, $this, 'This and that are equal'); $manager->isnt($this, $this, 'This and that are not equal'); $manager->like($this, qr/that/, 'This is matched by that'); $manager->unlike($this, qr/that/, 'This is not matched by that'); # class methods Badger::Test::Manager->plan(7); Badger::Test::Manager->ok($bool, 'This is a test'); Badger::Test::Manager->pass('This is ok'); Badger::Test::Manager->fail('This is not ok'); # ... plus is(), isnt(), like() unlike() methods, as above DESCRIPTIONThis module implements a simple test manager for Badger::Test. METHODSAll methods can be called as class methods or object methods. In the case of class methods, they are called against a prototype object returned by the prototype() method inherited from Badger::Prototype. plan($tests)How many tests you plan to run. An error will be thrown if you try to call this method twice. result($flag,@args)Low-level method to generate a test result. ok($flag, $name)Report on the success or failure of a test: $manager->ok(1, 'This is good'); $manager->ok(0, 'This is bad'); is($this, $that, $name)Test if the first two arguments are equal. $manager->is($this, $that, "This and that are equal"); isnt($this, $that, $name)Test if the first two arguments are not equal. $manager->isnt($this, $that, "This and that are equal"); like($text, qr/regex/, $name)Test if the first argument is matched by the regex passed as the second argument. $manager->like($this, qr/like that/i, "This and that are alike"); unlike($text, qr/regex/, $name)Test if the first argument is not matched by the regex passed as the second argument. $manager->unlike($this, qr/like that/i, "This and that are unalike"); pass($name)Pass a test. $manager->pass('Module Loaded'); fail($name)Fail a test. $manager->fail('Stonehenge crushed by a dwarf'); skip($reason)Skip a single test. $manager->skip("We don't have that piece of scenery any more"); skip_some($number,$reason)Skip a number of tests. $manager->skip_some(11, "We don't have that piece of scenery any more"); skip_rest(,$reason)Skip any remaining tests. $manager->skip_rest("We don't have that piece of scenery any more"); skip_all($reason)Skip all tests. This should be called instead of plan() $manager->skip_all("We don't have that piece of scenery any more"); colour($flag)Method to enable or disable colour mode. color($flag)An alias for colour(). INTERNAL METHODSfinish()This method is called automatically when the "Badger::Test::Manager" object is destroyed. It flushes any pending tests, performs any final sanity checks and prints a summary if requested. flush()This methods flushes any cached test results. You don't need to worry about it. summary()This method generates a final summary of the tests test_msg()Used to generate the test messages displayed via the Badger::Base messages() method. The message formats are defined in the $MESSAGES package variable. test_name()Use to generate a name for a test if one isn't explicitly provided. different($expect,$result)This method is call when a test find a result that doesn't match the expected value. If "Algorithm::Diff" is installed on your machine, it will generate a message showing how the output and expected values differ. Otherwise it will generate a regular message reporting the mismatch. AUTHORAndy Wardley <http://wardley.org/> COPYRIGHTCopyright (C) 1996-2009 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSOBadger::Test
|