TB2::Event - A test event role
package My::Event; use TB2::Mouse; with 'TB2::Event'; sub as_hash { ... } sub build_event_type { "my_thingy" }
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 end of a test 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.
The line on which this event occurred.
The event issuer should fill this in. It should be from the user's perspective, not literally where the event was created inside the builder.
The file on which this event occurred.
Returns the type of event this is. For example, "result" or "test_start".
Use this to identify events rather than $event->isa($class).
$event->isa($class)
See build_event_type for how to set the event_type if you're writing a new event.
event_type
You must implement these methods.
my $type = $event->build_event_type;
Returns the type of event this is.
For example, "result".
$type must be lowercase and only contain alphanumeric characters and underscores.
Used to build event_type
my $data = $event->as_hash;
Returns all the attributes and data associated with this $event as a hash of attributes and values.
$event
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.
my $keys = $event->keys_for_hash;
Returns an array ref of keys for as_hash to use as keys and methods to call on the object for the key's value.
as_hash
By default it uses the object's non-private attributes. That should be sufficient for most events.
my $id = $thing->object_id;
Returns an identifier for this object unique to the running process. The identifier is fairly simple and easily predictable.
See TB2::HasObjectID
TB2::Result
To install Test::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Simple
CPAN shell
perl -MCPAN -e shell install Test::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.