TEST2::EVENT::V2(3perl)

πŸ’– Test2::Event::V2 β€” the perl pragma doc, but make it cute πŸ’–

okay bestie, this is the page from the Perl Programmers Reference Guide for Test2::Event::V2, and it's genuinely one of my faves so let's get into it ✨


🌸 NAME 🌸

Test2::Event::V2 β€” the second generation event. glow-up event, fr fr πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, THIS is the event type you should be using. not Test2::Event, not its legacy subclasses β€” those are giving "hand-me-down", and this is giving main character energy. use this one instead. periodt πŸ’…


✨ SYNOPSIS ✨

πŸŽ€ USING A CONTEXT

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;
}

πŸŽ€ USING THE CONSTRUCTOR

use Test2::Event::V2;

my $e = Test2::Event::V2->new(
    trace => {frame => [$PKG, $FILE, $LINE, $SUBNAME]},
    info  => [{tag => 'NOTE', details => "This is a note"}],
);

πŸ‘‘ METHODS πŸ‘‘

heads up: this class inherits from Test2::Event. we're building on the family legacy πŸ’œ

  • $fd = $e->facet_data() β€” hands you back a hashref of facet data. every facet hash in there is a shallow copy of the original, so you can't mess with the real ones by accident. respectful king behavior 🫢
  • $about = $e->about() β€” gives you the 'about' facet hashref.
⚠️ NOTE: this gives you the internal hashref, NOT a copy. so like, pls be careful with it bestie 😭
  • $trace = $e->trace() β€” gives you the 'trace' facet, which is normally blessed (but that's not enforced when the trace gets set using set_trace()).
⚠️ NOTE: again, this is the internal trace, not a copy. literally the same warning, different facet πŸ™ˆ

πŸ”₯ MUTATION

  • $e->add_amnesty({...}) β€” inherited from Test2::Event. you use this to add 'amnesty' facets onto an event that already exists. each new item goes onto the END of the list.
πŸ’– NOTE: items ARE blessed when they get added. fancy.
  • $e->add_hub({...}) β€” inherited from Test2::Event. hubs use this to stamp events as they pass through. new items go onto the START of the list (yes, the opposite of the one above, stay woke πŸ‘€).
πŸ’€ NOTE: items ARE NOT blessed when they get added. no fancy for these ones.
  • $e->set_uuid($UUID) β€” inherited from Test2::Event, but overridden here so it also vivifies/mutates the 'about' facet. multitasking icon ⭐
  • $e->set_trace($trace) β€” inherited from Test2::Event, lets you swap out the trace.
⚠️ Note: this method does not bless/clone the trace for you. and a LOT of stuff out there expects the trace to be blessed, so like… you should probably do that yourself. not me having to tell you twice πŸ“

🌈 LEGACY SUPPORT METHODS

every single one of these is imported from Test2::Util::Facets2Legacy β€” go read that module or Test2::Event if you wanna know what they actually do, i'm not unlocking that lore here πŸ™ˆ

  • causes_fail
  • diagnostics
  • global
  • increments_count
  • no_display
  • sets_plan
  • subtest_id
  • summary
  • terminate

🧚 THIRD PARTY META-DATA 🧚

this object consumes Test2::Util::ExternalMeta, which gives you a consistent way to attach meta-data onto instances of this class. super useful if you're out here building tools, plugins, and other extensions β€” it's giving pluggable ✨


🌸 SOURCE 🌸

the source code repo for Test2 lives at https://github.com/Test-More/test-more/ β€” go be nosy, it's fine πŸ’œ


πŸ’… MAINTAINERS πŸ’…

Chad Granum <exodist@cpan.org>


πŸ‘‘ AUTHORS πŸ‘‘

Chad Granum <exodist@cpan.org>


Copyright 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 https://dev.perl.org/licenses/


and that's the whole page bestie, no cap 🫢 this was perl v5.44.0, dated 2026-10-17, from Test2::Event::V2(3perl). slay, go write some events πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms