Test2::...:Tester(3)
π NAME π
Okay bestie, this is the manual page for Test2::...:Tester(3) from the User Contributed Perl Documentation crew β and itβs literally a toolkit for testing your testing tools. Meta? Iconic. π
π¦ DESCRIPTION π¦
This is a collection of tools that are useful when youβre testing other test tools. No cap β itβs tooling for your tooling. π«Ά
β¨ SYNOPSIS β¨
use Test2::Tools::Tester qw/event_groups filter_events facets/;
use Test2::Tools::Basic qw/plan pass ok/;
use Test2::Tools::Compare qw/is like/;
my $events = intercept {
plan 11;
pass('pass');
ok(1, 'pass');
is(1, 1, "pass");
like(1, 1, "pass");
};
# Grab events generated by tools in Test2::Tools::Basic
my $basic = filter $events => 'Test2::Tools::Basic';
# Grab events generated by tools in Test2::Tools::Basic;
my $compare = filter $events => 'Test2::Tools::Compare';
# Grab events generated by tools named 'ok'.
my $oks = filter $events => qr/.*::ok$/;
my $grouped = group_events $events;
# Breaks events into this structure:
{
'__NA__' => [ ... ],
'Test2::Tools::Basic' => {
'__ALL__' => [ $events->[0], $events->[1], $events->[2] ],
plan => [ $events->[0] ],
pass => [ $events->[1] ],
ok => [ $events->[2] ],
},
Test2::Tools::Compare => { ... },
}
# Get an arrayref of all the assert facets from the list of events.
my $assert_facets = facets assert => $events;
# [
# bless({ details => 'pass', pass => 1}, 'Test2::EventFacet::Assert'),
# bless({ details => 'pass', pass => 1}, 'Test2::EventFacet::Assert'),
# ]
# Same, but for info facets
my $info_facets = facets info => $events;
π EXPORTS π
No subs are exported by default. You gotta ask for them, bestie. π
$array_ref = filter $events => $PACKAGEβ this one takes an arrayref of events as the first argument. All the extra arguments have to be either a package name or a regex. Any event generated by a tool in any of the packages, or by a tool matching any of the regexes, gets returned in an arrayref. Slay. β¨$array_ref = filter $events => $PACKAGE1, $PACKAGE2β samefilterenergy, multiple package names welcome.$array_ref = filter $events => qr/match/β samefilterenergy, but with a regex match.$array_ref = filter $events => qr/match/, $PACKAGEβ samefilterenergy, regex plus package. Mix and match, periodt.$grouped = group_events($events)β this function iterates all the events in the argument arrayref and splits them into groups. The resulting data structure is:
{ PACKAGE => { SUBNAME => [ $EVENT1, $EVENT2, ... }}
If the package of an event is not known, it will be put into an arrayref under the '__NA__' key at the root of the structure. If a sub name is not known, it will typically go under the '__ANON__' key under the package name. π
In addition, there is an '__ALL__' key under each package which stores all of the events sorted into that group.
A more complete example:
{
'__NA__' => [ $event->[3] ],
'Test2::Tools::Basic' => {
'__ALL__' => [ $events->[0], $events->[1], $events->[2] ],
plan => [ $events->[0] ],
pass => [ $events->[1] ],
ok => [ $events->[2] ],
},
}
$arrayref = facets TYPE => $eventsβ this function will compile a list of all facets of the specified type that are found in the arrayref of events. If the facet has a"Test2::EventFacet::TYPE"package available, then the facet will be constructed into an instance of the class; otherwise it is left as a hashref. Facet Order is preserved. π
my $assert_facets = facets assert => $events;
# [
# bless({ details => 'pass', pass => 1}, 'Test2::EventFacet::Assert'),
# bless({ details => 'pass', pass => 1}, 'Test2::EventFacet::Assert'),
# ]
π₯ SOURCE π₯
The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/. Go peek, bestie. π¦
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
πΈ AUTHORS πΈ
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
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 http://dev.perl.org/licenses/
Catch you in the group chat, bestie β this iconic page is from perl v5.42.0, dated 2025-07-28. π
β¨π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Test-Simple 1.302214-bp160.1.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms