Test2::Tools::HarnessTester(3pm) | User Contributed Perl Documentation | Test2::Tools::HarnessTester(3pm) |
Test2::Tools::HarnessTester - Run events through a harness for a summary
This tool allows you to process events through the Test2::Harness auditor. The main benefit here is to get a pass/fail result, as well as counts for assertions, failures, and errors.
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, } );
This takes an arrayref of events, such as that produced by "intercept {...}" from Test2::API. The result is a hashref that summarizes the results of the events as processed by Test2::Harness, specifically the Test2::Harness::Auditor::Watcher module.
Fields in the summary hash:
Note: This is reference to the original data, not a copy, if you modify it you will modify the event as well.
This will create a temporary directory with 't', 't2', and 'xt' subdirectories each of which will contain a single passing test.
This is re-exported from App::Yath::Tester.
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.
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/
2023-10-04 | perl v5.36.0 |