Badger::Test::Manager

NAME

Top Close Open

Badger::Test::Manager - test manager module

SYNOPSIS

Top Close Open
use 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

DESCRIPTION

Top Close Open

This module implements a simple test manager for Badger::Test.

METHODS

Top Close Open

All 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)

Top Close Open

How many tests you plan to run. An error will be thrown if you try to call this method twice.

result($flag,@args)

Top Close Open

Low-level method to generate a test result.

ok($flag, $name)

Top Close Open

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)

Top Close Open

Test if the first two arguments are equal.

$manager->is($this, $that, "This and that are equal");

isnt($this, $that, $name)

Top Close Open

Test if the first two arguments are not equal.

$manager->isnt($this, $that, "This and that are equal");

like($text, qr/regex/, $name)

Top Close Open

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)

Top Close Open

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)

Top Close Open

Pass a test.

$manager->pass('Module Loaded');

fail($name)

Top Close Open

Fail a test.

$manager->fail('Stonehenge crushed by a dwarf');

skip($reason)

Top Close Open

Skip a single test.

$manager->skip("We don't have that piece of scenery any more");

skip_some($number,$reason)

Top Close Open

Skip a number of tests.

$manager->skip_some(11, "We don't have that piece of scenery any more");

skip_rest(,$reason)

Top Close Open

Skip any remaining tests.

$manager->skip_rest("We don't have that piece of scenery any more");

skip_all($reason)

Top Close Open

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)

Top Close Open

Method to enable or disable colour mode.

color($flag)

Top Close Open

An alias for colour().

INTERNAL METHODS

Top Close Open

finish()

Top Close Open

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()

Top Close Open

This methods flushes any cached test results. You don't need to worry about it.

summary()

Top Close Open

This method generates a final summary of the tests

test_msg()

Top Close Open

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()

Top Close Open

Use to generate a name for a test if one isn't explicitly provided.

different($expect,$result)

Top Close Open

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.

AUTHOR

Top Close Open

Andy Wardley http://wardley.org/

COPYRIGHT

Top Close Open

Copyright (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.

Fork Me on Github