Test2:...sTester(3pm)
π Test2::Tools::HarnessTester β perl manual page, section 3pm π
okay bestie, this one's a 3pm page out of the User Contributed Perl Documentation, and it's genuinely so useful, come sit with me π«Ά
β¨ NAME β¨
Test2::Tools::HarnessTester β run events through a harness for a summary π
πΈ DESCRIPTION πΈ
So this tool lets you process events through the Test2::Harness auditor. The whole point, the main character benefit, is that you get a pass/fail result, plus counts for assertions, failures, and errors. That's it, that's the vibe. β¨
π¦ SYNOPSIS π¦
use Test2::V0;
use Test2::API qw/intercept/;
use Test2::Tools::HarnessTester qw/summarize_events/;
my $events = intercept {
ok(1, "pass");
ok(2, "pass gain");
done_testing;
};
is(
summarize_events($events),
{
# Each of these is the negation of the other, no need to check both
pass => 1,
fail => 0,
# The plan facet, see Test2::EventFacet::Plan
plan => {count => 2},
# Statistics
assertions => 2,
errors => 0,
failures => 0,
}
);
π EXPORTS π
π $summary = summarize_events($events)
This takes an arrayref of events, like the one you get out of "intercept {...}" from Test2::API. What you get back is a hashref that summarizes the results of those events as processed by Test2::Harness, specifically the Test2::Harness::Auditor::Watcher module. no cap π₯
Fields in the summary hash:
pass => $BOOLfail => $BOOL
These are negatives of eachother, fr fr. They're the pass/fail state after processing the events. When one is true the other should be false. They get normalized to 1 and 0.
plan => $HASHREF
If a plan was provided, this will have the Test2::EventFacet::Plan facet β but as a hashref, not a blessed instance.
Note: This is reference to the original data, not a copy, if you modify it you will modify the event as well. π so like, be careful bestie, it's giving shared state.
assertions => $INTCount of assertions made.errors => $INTCount of errors seen.failures => $INTCount of failures seen.
π§ $path = make_example_dir()
This will create a temporary directory with t, t2, and xt subdirectories, each of which will contain a single passing test. iconic tbh π
This is re-exported from App::Yath::Tester.
π SOURCE π
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/. go look, it's right there π
β MAINTAINERS β
Chad Granum <exodist@cpan.org>
πΈ AUTHORS πΈ
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
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/
and that's the whole page, bestie π«Ά this lil doc shipped as perl v5.40.1, dated 2026-05-10 β periodt β¨π
π¦ where this page comes from
- ubuntu stonking: libtest2-harness-perl 1.000172-1 Β· Artistic-1.0-Perl OR 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