Test2::Event::V2(3p) Perl Programmers Reference Guide Test2::Event::V2(3p) #
Test2::Event::V2(3p) Perl Programmers Reference Guide Test2::Event::V2(3p)
NNAAMMEE #
Test2::Event::V2 - Second generation event.
DDEESSCCRRIIPPTTIIOONN #
This is the event type that should be used instead of Test2::Event or its
legacy subclasses.
SSYYNNOOPPSSIISS #
UUSSIINNGG AA CCOONNTTEEXXTT #
use Test2::API qw/context/;
sub my_tool {
my $ctx = context();
my $event = $ctx->send_ev2(info => [{tag => 'NOTE', details => "This is a note"}]);
$ctx->release;
return $event;
}
UUSSIINNGG TTHHEE CCOONNSSTTRRUUCCTTOORR #
use Test2::Event::V2;
my $e = Test2::Event::V2->new(
trace => {frame => [$PKG, $FILE, $LINE, $SUBNAME]},
info => [{tag => 'NOTE', details => "This is a note"}],
);
MMEETTHHOODDSS #
This class inherits from Test2::Event.
$fd = $e->ffaacceett__ddaattaa(())
This will return a hashref of facet data. Each facet hash will be a
shallow copy of the original.
$about = $e->aabboouutt(())
This will return the 'about' facet hashref.
NNOOTTEE:: This will return the internal hashref, not a copy.
$trace = $e->ttrraaccee(())
This will return the 'trace' facet, normally blessed (but this is not
enforced when the trace is set using "set_trace()".
NNOOTTEE:: This will return the internal trace, not a copy.
MMUUTTAATTIIOONN #
$e->add_amnesty({...})
Inherited from Test2::Event. This can be used to add 'amnesty' facets
to an existing event. Each new item is added to the EENNDD of the list.
NNOOTTEE:: Items AARREE blessed when added.
$e->add_hub({...})
Inherited from Test2::Event. This is used by hubs to stamp events as
they pass through. New items are added to the SSTTAARRTT of the list.
NNOOTTEE:: Items AARREE NNOOTT blessed when added.
$e->set_uuid($UUID)
Inherited from Test2::Event, overridden to also vivify/mutate the
'about' facet.
$e->set_trace($trace)
Inherited from Test2::Event which allows you to change the trace.
NNoottee:: This method does not bless/clone the trace for you. Many things
will expect the trace to be blessed, so you should probably do that.
LLEEGGAACCYY SSUUPPPPOORRTT MMEETTHHOODDSS #
These are all imported from Test2::Util::Facets2Legacy, see that module
or Test2::Event for documentation on what they do.
causes_fail
diagnostics
global
increments_count
no_display
sets_plan
subtest_id
summary
terminate
TTHHIIRRDD PPAARRTTYY MMEETTAA--DDAATTAA #
This object consumes Test2::Util::ExternalMeta which provides a
consistent way for you to attach meta-data to instances of this class.
This is useful for tools, plugins, and other extensions.
SSOOUURRCCEE #
The source code repository for Test2 can be found at
_h_t_t_p_:_/_/_g_i_t_h_u_b_._c_o_m_/_T_e_s_t_-_M_o_r_e_/_t_e_s_t_-_m_o_r_e_/.
MMAAIINNTTAAIINNEERRSS #
Chad Granum <exodist@cpan.org>
AAUUTTHHOORRSS #
Chad Granum <exodist@cpan.org>
CCOOPPYYRRIIGGHHTT #
Copyright 2020 Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See _h_t_t_p_:_/_/_d_e_v_._p_e_r_l_._o_r_g_/_l_i_c_e_n_s_e_s_/
perl v5.36.3 2023-02-15 Test2::Event::V2(3p)