1Test2::Event::Generic(3U)ser Contributed Perl DocumentatiToenst2::Event::Generic(3)
2
3
4

NAME

6       Test2::Event::Generic - Generic event type.
7

DESCRIPTION

9       This is a generic event that lets you customize all fields in the event
10       API.  This is useful if you have need for a custom event that does not
11       make sense as a published reusable event subclass.
12

SYNOPSIS

14           use Test2::API qw/context/;
15
16           sub send_custom_fail {
17               my $ctx = shift;
18
19               $ctx->send_event('Generic', causes_fail => 1, summary => 'The sky is falling');
20
21               $ctx->release;
22           }
23
24           send_custom_fail();
25

METHODS

27       $e->facet_data($data)
28       $data = $e->facet_data
29           Get or set the facet data (see Test2::Event). If no facet_data is
30           set then "Test2::Event->facet_data" will be called to produce
31           facets from the other data.
32
33       $e->callback($hub)
34           Call the custom callback if one is set, otherwise this does
35           nothing.
36
37       $e->set_callback(sub { ... })
38           Set the custom callback. The custom callback must be a coderef. The
39           first argument to your callback will be the event itself, the
40           second will be the Test2::Event::Hub that is using the callback.
41
42       $bool = $e->causes_fail
43       $e->set_causes_fail($bool)
44           Get/Set the "causes_fail" attribute. This defaults to 0.
45
46       $bool = $e->diagnostics
47       $e->set_diagnostics($bool)
48           Get/Set the "diagnostics" attribute. This defaults to 0.
49
50       $bool_or_undef = $e->global
51       @bool_or_empty = $e->global
52       $e->set_global($bool_or_undef)
53           Get/Set the "diagnostics" attribute. This defaults to an empty list
54           which is undef in scalar context.
55
56       $bool = $e->increments_count
57       $e->set_increments_count($bool)
58           Get/Set the "increments_count" attribute. This defaults to 0.
59
60       $bool = $e->no_display
61       $e->set_no_display($bool)
62           Get/Set the "no_display" attribute. This defaults to 0.
63
64       @plan = $e->sets_plan
65           Get the plan if this event sets one. The plan is a list of up to 3
66           items: "($count, $directive, $reason)". $count must be defined, the
67           others may be undef, or may not exist at all.
68
69       $e->set_sets_plan(\@plan)
70           Set the plan. You must pass in an arrayref with up to 3 elements.
71
72       $summary = $e->summary
73       $e->set_summary($summary_or_undef)
74           Get/Set the summary. This will default to the event package
75           'Test2::Event::Generic'. You can set it to any value. Setting this
76           to "undef" will reset it to the default.
77
78       $int_or_undef = $e->terminate
79       @int_or_empty = $e->terminate
80       $e->set_terminate($int_or_undef)
81           This will get/set the "terminate" attribute. This defaults to undef
82           in scalar context, or an empty list in list context. Setting this
83           to undef will clear it completely. This must be set to a positive
84           integer (0 or larger).
85

SOURCE

87       The source code repository for Test2 can be found at
88       http://github.com/Test-More/test-more/.
89

MAINTAINERS

91       Chad Granum <exodist@cpan.org>
92

AUTHORS

94       Chad Granum <exodist@cpan.org>
95
97       Copyright 2018 Chad Granum <exodist@cpan.org>.
98
99       This program is free software; you can redistribute it and/or modify it
100       under the same terms as Perl itself.
101
102       See http://dev.perl.org/licenses/
103
104
105
106perl v5.26.3                      2018-03-30          Test2::Event::Generic(3)
Impressum