NAME

Test::Suite::Plugin - Used by plugins to turn them into plugins.

DESCRIPTION

All plugins must use this class to define their exported functionality.

EARLY VERSION WARNING

This is VERY early version. Test::Suite does not run yet.

Please go to http://github.com/exodist/Test-Suite to see the latest and greatest.

SYNOPSYS

To create a plugin create a module directly under the Test::Suite::Plugin namespace. Define testers and utilies.

package Test::Suite::Plugin::MyPlugin;
use strict;
use references;
use Test::Suite::Plugin;

# define a util function
util my_diag => sub { Test::Suite->diag( @_ ) };

# define a tester
tester my_ok => (
    min_args => 1,
    max_args => 2,
    code => sub {
        my ( $result, $name ) = @_;
        return ( $result ? 1 : 0, $name );
    },
);

# Define one with a prototype
tester my_dies_ok => sub(&;$) {
    eval $_[0]->() || return ( 1, $_[1]);
    Test::Suite->diag( "Test did not die as expected" );
    return ( 0, $_[1] );
};

1;

WRAPPER PLUGINS

Plugins can be made to wrap around existing Test::Builder based testing utilities. This is how Test::More and Test::Warn functionality is provided. Here is the Test::More wrapper plugin as an example.

package Test::Suite::Plugin::More;
use strict;
use warnings;

use Test::Suite::Plugin;

our @SUBS;
BEGIN {
    @SUBS = qw/ is isnt like unlike cmp_ok is_deeply can_ok isa_ok /;
}

use Test::More import => \@SUBS;

tester $_ => $_ for @SUBS;
util diag => sub { Test::Suite->diag( @_ ) };
util todo => sub(&$) {
    my ( $code, $todo ) = @_;
    local $Test::Suite::Plugin::TODO = $todo;
    $code->();
};

1;

TESTING

TODO

ADVANCED TESTERS

TODO - talk about defining argument types

IMPORT

CLASS METHODS

my $reason = $class->todo()

If the tests are currently runnign under TODO this will returnt he reason, otherwise it will return false.

$class->export_to( $package )

Export testers and utils from the plugin to the specified package.

EXPORTED FUNCTIONS

These functions are exported for use in your plugins.

no_test()

If a tester sub returns the result of this function then no test will be recorded. This can be used to abord a tester without any record.

util( $name, $code )
util( $name, %proto )

Define a utility function.

tester( $name, $code )
tester( $name, %proto )

Define a tester function.

AUTHORS

Chad Granum exodist7@gmail.com

COPYRIGHT

Copyright (C) 2010 Chad Granum

Test-Suite is free software; Standard perl licence.

Test-Suite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.