TAP::Formatter::Event - event interface to TAP::Formatter or TAP::Harness::Async
version 0.001
use TAP::Harness; use TAP::Formatter::Event; my $harness = TAP::Harness->new({ formatter => TAP::Formatter::Event->new({ verbosity => 1 })->add_handler_for_event( test_failed => sub { my ($self, $session, $test) = @_; print "Failed test: " . $test->description . "\n"; } ), }); $harness->runtests(@ARGV);
Used by some examples in TAP::Harness::Async. Note that TAP::Harness provides an event interface already, so unless you're specifically after the async approach for running tests then you may be better served by "CALLBACKS" in TAP::Parser.
Normally all methods would be called from TAP::Harness::Async. See Mixin::Event::Dispatch and TAP::Formatter::Base for other available methods.
Events are triggered through the "invoke_event" in Mixin::Event::Dispatch interface, use "add_handler_for_event" in Mixin::Event::Dispatch to attach handlers as required. Unhandled events are ignored.
Example:
my $file; $formatter->add_handler_for_event( test_failed => sub { warn "Test failed: " . $_[1]->description }, new_session => sub { my ($self, $session) = @_; $file = $session->name; warn "Started session for [$file]"; return $self; }, test_passed => sub { my ($self, $test) = @_; warn "Test passed, description: " . $test->description; ++$passed{$self->testfile}; $self; } );
Called when a new session ("test file") starts.
Receives a single TAP::Parser::Result object.
A test run has started.
We have received a single result.
This is the plan for the current test.
A test has passed.
A test has failed.
Unknown test result.
A test file has finished.
The summary results are ready.
TAP::Formatter
TAP::Formatter::Session
TAP::Harness
Tom Molesworth <cpan@entitymodel.com>
Copyright Tom Molesworth 2011-2012. Licensed under the same terms as Perl itself.
To install TAP::Formatter::Event, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TAP::Formatter::Event
CPAN shell
perl -MCPAN -e shell install TAP::Formatter::Event
For more information on module installation, please visit the detailed CPAN module installation guide.