1Test::Stream::Event(3)User Contributed Perl DocumentationTest::Stream::Event(3)
2
3
4

NAME

6       Test::Stream::Event - Base class for events
7

DEPRECATED

9       This distribution is deprecated in favor of Test2, Test2::Suite, and
10       Test2::Workflow.
11
12       See Test::Stream::Manual::ToTest2 for a conversion guide.
13

DESCRIPTION

15       Base class for all event objects that get passed through Test::Stream.
16

SYNOPSIS

18           package Test::Stream::Event::MyEvent;
19           use strict;
20           use warnings;
21
22           # This will make our class an event subclass (required)
23           use base 'Test::Stream::Event';
24
25           # Add some accessors
26           use Test::Stream::HashBase accessors => [qw/foo bar baz/];
27
28           # Chance to initialize some defaults
29           sub init {
30               my $self = shift;
31               # no other args in @_
32
33               $self->SUPER::init();
34
35               $self->set_foo('xxx') unless defined $self->foo;
36
37               # Events are arrayrefs, all accessors have a constant defined with
38               # their index.
39               $self->[BAR] ||= "";
40
41               ...
42           }
43
44           1;
45

METHODS

47       $dbg = $e->debug
48           Get a snapshot of the debug info as it was when this event was
49           generated
50
51       $bool = $e->causes_fail
52           Returns true if this event should result in a test failure. In
53           general this should be false.
54
55       $call = $e->created
56           Get the "caller()" details from when the event was generated. This
57           is usually inside a tools package. This is typically used for
58           debugging.
59
60       $num = $e->nested
61           If this event is nested inside of other events, this should be the
62           depth of nesting. (This is mainly for subtests)
63
64       $e->update_state($state)
65           This callback is used by Test::Stream::Hub to give your event a
66           chance to update the state.
67
68           This is called BEFORE your event is passed to the formatter.
69
70       $bool = $e->global
71           Set this to true if your event is global, that is ALL threads and
72           processes should see it no matter when or where it is generated.
73           This is not a common thing to want, it is used by bail-out and
74           skip_all to end testing.
75
76       $code = $e->terminate
77           This is called AFTER your event has been passed to the formatter.
78           This should normally return undef, only change this if your event
79           should cause the test to exit immedietly.
80
81           If you want this event to cause the test to exit you should return
82           the exit code here. Exit code of 0 means exit success, any other
83           integer means exit with failure.
84
85           This is used by Test::Stream::Event::Plan to exit 0 when the plan
86           is 'skip_all'. This is also used by Test::Stream::Event:Bail to
87           force the test to exit with a failure.
88
89           This is called after the event has been sent to the formatter in
90           order to ensure the event is seen and understood.
91
92       @output = $e->to_tap($num)
93           This is where you get the chance to produce TAP output. The input
94           argument $num will either be the most recent test number, or
95           undefined. The output should be a list of arrayrefs, each arrayref
96           should have exactly 2 values: "$HID, $TEXT". The HID tells the
97           formatter which output handle to use (see the constants provided by
98           Test::Stream::Formatter::TAP), $TEXT should be the text that is
99           output to the specified handle.
100
101           Example:
102
103               package Test::Stream::Event::MyEvent;
104               use base 'Test::Stream::Event';
105               use Test::Stream::Formatter::TAP qw/OUT_STD OUT_TODO OUT_ERR/;
106
107               sub to_tap {
108                   my $self = shift;
109                   my ($num) = @_;
110
111                   # Using test numbers
112                   if (defined $num) {
113                       return (
114                           [OUT_STD, "# Got MyEvent!"],
115                           [OUT_ERR, "# The last test was $num"],
116                       );
117                   }
118
119                   # Not using test numbers.
120                   return (
121                       [OUT_STD, "# Got MyEvent!"],
122                   );
123               }
124

SOURCE

126       The source code repository for Test::Stream can be found at
127       http://github.com/Test-More/Test-Stream/.
128

MAINTAINERS

130       Chad Granum <exodist@cpan.org>
131

AUTHORS

133       Chad Granum <exodist@cpan.org>
134
136       Copyright 2015 Chad Granum <exodist7@gmail.com>.
137
138       This program is free software; you can redistribute it and/or modify it
139       under the same terms as Perl itself.
140
141       See http://dev.perl.org/licenses/
142
143
144
145perl v5.32.1                      2021-01-27            Test::Stream::Event(3)
Impressum