++ed by:
ALEXBIO PATCH DOLMEN KARJALA YANICK

94 PAUSE users
66 non-PAUSE users.

Chad Granum
and 1 contributors

NAME

Test::Builder::Formatter - Base class for formatters

DESCRIPTION

Events go to Test::Builder::Stream which then forwards them on to one or more formatters. This module is a base class for formatters. You do not NEED to use this module to write a formatter, but it can help.

TEST COMPONENT MAP

  [Test Script] > [Test Tool] > [Test::Builder] > [Test::Bulder::Stream] > [Event Formatter]
                                                                                   ^
                                                                             You are here

A test script uses a test tool such as Test::More, which uses Test::Builder to produce events. The events are sent to Test::Builder::Stream which then forwards them on to one or more formatters. The default formatter is Test::Builder::Fromatter::TAP which produces TAP output.

SYNOPSYS

    package My::Formatter;
    use base 'Test::Builder::Formatter';

    sub ok {
        my $self = shift;
        my ($event) = @_;

        ...
    }

    ...

    1;

TO USE IT

    use Test::More;
    use My::Formatter;

    # Creates a new instance of your listener. Any params you pass in will be
    # passed into the constructor. Exceptions: 'id', 'stream' and 'tb' which
    # are used directly by 'listen' if present.
    my $unlisten = My::Formatter->listen(...);

    # To stop listening:
    $unlisten->();

METHODS

PROVIDED

$L = $class->new(%params)

Create a new instance. Arguments must be key => value pairs where the key is a method name on the object.

$unlisten = $class->listen(%params)
$unlisten = $class->listen(id => 'foo', %params)
$unlisten = $class->listen(stream => $STREAM, %params)
$unlisten = $class->listen(tb => $BUILDER, %params)

Construct an instance using %params, and add it as a listener on the stream. 'id', 'stream', and 'tb' are special arguments that can be used to specify the id of the listener, the stream to which the instance will listen, or the Test::Builder instance from which to find the stream.

$L->handle($event)

Forward the event on to the correct method.

$subref = $L->to_handler()

Returns an anonymous sub that accepts events as arguments and passes them into handle() on this instance.

FOR YOU TO WRITE

$self->ok($event)
$self->note($event)
$self->diag($event)
$self->plan($event)
$self->finish($event)
$self->bail($event)
$self->child($event)

Any events given to the handle() method will be passed into the associated sub. If the sub is not defined then events of that type will be ignored.

AUTHORS

Chad Granum <exodist@cpan.org>

SOURCE

The source code repository for Test::More can be found at http://github.com/Test-More/test-more/.

COPYRIGHT

Copyright 2014 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html