1Test2::Tools::HarnessTeUssteerr(C3o)ntributed Perl DocumTeenstta2t:i:oTnools::HarnessTester(3)
2
3
4

NAME

6       Test2::Tools::HarnessTester - Run events through a harness for a
7       summary
8

DESCRIPTION

10       This tool allows you to process events through the Test2::Harness
11       auditor.  The main benefit here is to get a pass/fail result, as well
12       as counts for assertions, failures, and errors.
13

SYNOPSIS

15           use Test2::V0;
16           use Test2::API qw/intercept/;
17           use Test2::Tools::HarnessTester qw/summarize_events/;
18
19           my $events = intercept {
20               ok(1, "pass");
21               ok(2, "pass gain");
22               done_testing;
23           };
24
25           is(
26               summarize_events($events),
27               {
28                   # Each of these is the negation of the other, no need to check both
29                   pass       => 1,
30                   fail       => 0,
31
32                   # The plan facet, see Test2::EventFacet::Plan
33                   plan       => {count => 2},
34
35                   # Statistics
36                   assertions => 2,
37                   errors     => 0,
38                   failures   => 0,
39               }
40           );
41

EXPORTS

43   $summary = summarize_events($events)
44       This takes an arrayref of events, such as that produced by "intercept
45       {...}" from Test2::API. The result is a hashref that summarizes the
46       results of the events as processed by Test2::Harness, specifically the
47       Test2::Harness::Auditor::Watcher module.
48
49       Fields in the summary hash:
50
51       pass => $BOOL
52       fail => $BOOL
53           These are negatives of eachother. These represent the pass/fail
54           state after processing the events. When one is true the other
55           should be false. These are normalized to 1 and 0.
56
57       plan => $HASHREF
58           If a plan was provided this will have the Test2::EventFacet::Plan
59           facet, but as a hashref, not a blessed instance.
60
61           Note: This is reference to the original data, not a copy, if you
62           modify it you will modify the event as well.
63
64       assertions => $INT
65           Count of assertions made.
66
67       errors => $INT
68           Count of errors seen.
69
70       failures => $INT
71           Count of failures seen.
72
73   $path = make_example_dir()
74       This will create a temporary directory with 't', 't2', and 'xt'
75       subdirectories each of which will contain a single passing test.
76
77       This is re-exported from App::Yath::Tester.
78

SOURCE

80       The source code repository for Test2-Harness can be found at
81       http://github.com/Test-More/Test2-Harness/.
82

MAINTAINERS

84       Chad Granum <exodist@cpan.org>
85

AUTHORS

87       Chad Granum <exodist@cpan.org>
88
90       Copyright 2020 Chad Granum <exodist7@gmail.com>.
91
92       This program is free software; you can redistribute it and/or modify it
93       under the same terms as Perl itself.
94
95       See http://dev.perl.org/licenses/
96
97
98
99perl v5.34.1                      2022-07-11    Test2::Tools::HarnessTester(3)
Impressum