The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Builder2::Event - A test event role

SYNOPSIS

    package My::Event;

    use Test::Builder2::Mouse;
    with 'Test::Builder2::Event';

    sub as_hash    { ... }
    sub event_type { return "thingy" }

DESCRIPTION

Test::Builder2 is a federated system where multiple builders can define their own way to do asserts. They communicate and coordinate with each other by way of events. These events can include:

    start of a test stream
    end of a test stream
    the result of an assert

The basic Event doesn't do a whole lot. It contains data and that's about it. Subclasses are expected to extend the interface quite a bit, but they will all be able to dump out their relevant data.

METHODS

Required Methods

You must implement these methods.

event_type

    my $type = $event->event_type;

Returns the type of event this is.

For example, "result".

as_hash

    my $data = $event->as_hash;

Returns all the data associated with this $event as a hash of attributes and values.

The intent is to provide a way to dump all the information in an Event without having to call methods which may or may not exist.

Provided Methods

event_id

    my $id = $event->event_id;

Returns an identifier for this event unique to this process.

Useful if an EventWatcher posts its own events and doesn't want to process them twice.

SEE ALSO

Test::Builder2::Result