1Test2::Harness::Event(3U)ser Contributed Perl DocumentatiToenst2::Harness::Event(3)
2
3
4
6 Test2::Harness::Event - Subclass of Test2::Event used by Test2::Harness
7 under the hood.
8
10 Test2 tests produce a sequence of events objects Test2::Event. This is
11 a subclass of those events for use in Test2::Harness. Event non-test
12 tests which produce TAP output will have the output parsed into these
13 types of events.
14
16 In normal usage ou will never need to create one fo these events
17 yourself. This documentation assumes you are operating on an existing
18 event $event that the harness exposed to you via a plugin or similar.
19
20 my $facet_data = $event->facet_data;
21 my $run_id = $event->run_id;
22 my $job_id = $event->job_id;
23 my $job_try = $event->job_try;
24 my $event_id = $event->event_id;
25
27 See Test2::Event for methods provided by the base class.
28
29 $hashref = $event->TO_JSON
30 Used for json serialization.
31
32 $json_string = $event->as_json
33 This will return a json representation of the event. Note that this
34 is a lossy conversion with some harness specific state removed by
35 design. This may even be a cached copy of the json string that was
36 decoded to produce the original object. If the string was not
37 cached before it will be cached for all future calls ignoring any
38 state change to the event.
39
40 The lossy/cached conversion is intended so that events get passed
41 through the harness pipeline without modifications from one step
42 translating to another. If you need something extra to go through
43 you need to either replace the event or create an additional one.
44
45 $string = $event->event_id
46 Usually a UUID, but not always!
47
48 i$hashref = $event->facet_data
49 Get the event facet data, this is the meat of the event that hold
50 all the state.
51
52 $string = $event->job_id
53 Usually a UUID, but not always!
54
55 $int = $event->job_try
56 Integer, 0 or greater. Some jobs are run additional times if they
57 fail, this says which attempt the event is for. The counter starts
58 at 0.
59
60 $bool = $event->processed
61 This will be true if the event has been process by the harness.
62 Note that this attibute is not serialized by "TO_JSON" or
63 "as_json".
64
65 $string = $event->run_id
66 The run id. This is usually a UUID, but not always!
67
68 $ts = $event->stamp
69 A unix timestamp for when the event was created.
70
71 $id = $event->stream_id
72 This is an implementation detail of Test2::Formatter::Stream, do
73 not rely on it. This is used to prevent parsing errors when stream
74 output is nested in other stream output, which can happen if you
75 are writing tests for the stream formatter itself.
76
77 $trace = $event->trace
78 This si a shortcut for "$event->facet_data->{trace}". The trace
79 data is essential and used everywhere.
80
82 The source code repository for Test2-Harness can be found at
83 http://github.com/Test-More/Test2-Harness/.
84
86 Chad Granum <exodist@cpan.org>
87
89 Chad Granum <exodist@cpan.org>
90
92 Copyright 2020 Chad Granum <exodist7@gmail.com>.
93
94 This program is free software; you can redistribute it and/or modify it
95 under the same terms as Perl itself.
96
97 See http://dev.perl.org/licenses/
98
99
100
101perl v5.38.0 2023-10-04 Test2::Harness::Event(3)