Test2:...::Event(3pm)

πŸ’– Test2::...::Event πŸ’–

okay bestie so real quick β€” this page is from the User Contributed Perl Documentation collection, and it's all about Test2::Harness::Event. we're talking the manual page for it, Test2:...::Event(3pm), and yes the name is genuinely that scrunched up, no I did not do that, that's just how it is. πŸŽ€


✨ NAME ✨

Test2::Harness::Event β€” bestie it's a subclass of Test2::Event that Test2::Harness uses under the hood. lowkey iconic behavior, honestly. πŸ‘‘


🌸 DESCRIPTION 🌸

okay so here's the lore. Test2 tests spit out a whole sequence of event objects, right? and those are Test2::Event objects. this class is a subclass of those, made specifically for use inside Test2::Harness.

and here's the cute part β€” non-test tests that produce TAP output? the harness takes that output and parses it into these types of events. so like, the raw TAP gets glow-upped into real event objects. it's giving translation era. πŸ¦‹


✨ SYNOPSIS ✨

fr fr, in normal usage you will never need to create one of these events yourself. so this documentation is assuming a whole different vibe: you've already got an existing event called $event that the harness handed to you through a plugin or something similar. 🫢

my $facet_data = $event->facet_data;
my $run_id     = $event->run_id;
my $job_id     = $event->job_id;
my $job_try    = $event->job_try;
my $event_id   = $event->event_id;

look at that. five little lines. so tidy. so organized. we love a well-formatted synopsis. πŸ’…


πŸ’… METHODS πŸ’…

for everything the base class gives you, go peek at Test2::Event. that's where those methods live.

  • $hashref = $event->TO_JSON β€” this one is used for json serialization. that's the whole job. ✨
  • $json_string = $event->as_json β€” returns a json representation of the event. but heads up bestie, this is a lossy conversion β€” some harness-specific state gets removed, and that's on purpose, by design. it might even be a cached copy of the json string that was decoded to produce the original object in the first place. and if the string wasn't cached before? it gets cached now, for all future calls, ignoring any state change to the event. periodt.

the whole lossy/cached conversion situation exists so that events get passed through the harness pipeline without modifications from one step translating to another. so if you need something extra to go through? you've gotta either replace the event or create an additional one. no shortcuts, no cap.

  • $string = $event->event_id β€” usually a UUID, but not always! 😭
  • i$hashref = $event->facet_data β€” get the event facet data. this is literally the meat of the event, it holds all the state. the whole main character. πŸ‘‘
  • $string = $event->job_id β€” usually a UUID, but not always! πŸ’€
  • $int = $event->job_try β€” an integer, 0 or greater. some jobs get run additional times if they fail, and this tells you which attempt the event belongs to. the counter starts at 0. yes, zero. we're programmers, we start at zero, it's fine. πŸ™ˆ
  • $bool = $event->processed β€” true if the event has been processed by the harness. but note bestie: this attribute is not serialized by TO_JSON or as_json. it does not travel. it stays home. 🏠
  • $string = $event->run_id β€” the run id. usually a UUID, but not always! ⭐
  • $ts = $event->stamp β€” a unix timestamp for when the event was created. the event's birthday, basically. πŸŽ‚
  • $id = $event->stream_id β€” okay so this one is an implementation detail of Test2::Formatter::Stream, so do not rely on it. ngl. it exists to prevent parsing errors when stream output is nested inside other stream output β€” which can totally happen if you're writing tests for the stream formatter itself. so it's a little internal bodyguard. 🧚
  • $trace = $event->trace β€” this is a shortcut for $event->facet_data->{trace}. the trace data is essential and it's used everywhere. everywhere. everywhere. πŸ”₯

πŸŽ€ SOURCE πŸŽ€

the source code repository for Test2-Harness lives at http://github.com/Test-More/Test2-Harness/. go scroll, bestie, it's right there. 🌈


πŸ‘‘ MAINTAINERS πŸ‘‘

Chad Granum <exodist@cpan.org>


πŸ’œ AUTHORS πŸ’œ

Chad Granum <exodist@cpan.org>


Copyright 2020 Chad Granum <exodist7@gmail.com>.

this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

see http://dev.perl.org/licenses/ for the whole legal situation. πŸ“œ


okay that's the whole page!! every method, every flag, every UUID-but-not-always, all of it. nothing skipped, nothing summarized, we keep the facts and we keep the vibes. πŸ’–

and finally, the cute little sign-off that lives at the bottom of the original: this one's rocking perl v5.40.1, dated 2026-05-10, and it's the Test2:...::Event(3pm) page. thanks for reading bestie, go write some tests, slay, bye!! πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from