1Test2::Harness::Log::CoUvseerragCeoAngtgrriebguatteToders(Pt3e2)r:l:HDaorcnuemsesn:t:aLtoigo:n:CoverageAggregator(3)
2
3
4

NAME

6       Test2::Harness::Log::CoverageAggregator - Module for aggregating
7       coverage data from a stream of events.
8

DESCRIPTION

10       This module takes a stream of events and produces aggregated coverage
11       data.
12

SYNOPSIS

14           use Test2::Harness::Log::CoverageAggregator;
15
16           my $agg = Test2::Harness::Log::CoverageAggregator->new();
17
18           while (my $e = $log->next_event) {
19               $agg->process_event($e);
20           }
21
22           # Get a structure like { source_file => { source_method => $touched_count, ... }, ...}
23           my $touched_source = $agg->touched;
24
25           # Get a structure like
26           # {
27           #     files => {total => 5,  tested => 2},
28           #     subs  => {total => 20, tested => 12},
29           #     untested => {files => \@file_list, subs => {file => \@sub_list, ...}},
30           # }
31           my $metrics = $agg->metrics;
32

METHODS

34   IMPLEMENTABLE IN SUBLCASSES
35       If you implement these in a subclass they will be called for you at the
36       proper times, making subclassing much easier. In most cases you can
37       avoid overriding process_event().
38
39       $agg->start_test($test, $event)
40           This is called once per test when it starts.
41
42           Note: If a test is run more than once (re-run) it will start and
43           stop again for each re-run. The event is also provided as an
44           argument so that you can check for a try-id or similar in the event
45           that re-runs matter to you.
46
47       $agg->stop_test($test, $event)
48           This is called once per test when it stops.
49
50           Note: If a test is run more than once (re-run) it will start and
51           stop again for each re-run. The event is also provided as an
52           argument so that you can check for a try-id or similar in the event
53           that re-runs matter to you.
54
55       $agg->record_coverage($test, $coverage_data, $event)
56           This is called once per coverage event (there can be several in a
57           test, specially if it forks or uses threads).
58
59           In most cases you probably want to leave this unimplemented and
60           implement the "touch()" method instead of iterating over the
61           coverage structure yourself.
62
63       $agg->touch(source => $file, sub => $sub, test => $test, manager_data
64       => $mdata, event => $event)
65           Every touch applied to a source file (and sub) will trigger this
66           method call.
67
68           source => $file
69               The source file that was touched
70
71           sub => $sub
72               The source subroutine that was touched. Note: This may be '<>'
73               if the source file was opened via "open()" or '*' if code
74               outside of a subroutine was executed by the test.
75
76           test => $test
77               The test file that did the touching.
78
79           manager_data => $mdata
80               If the test file makes use of a source manager to attach extra
81               data to coverage, this is where that data will be. A good
82               example would be test suites that use tools similar to
83               Test::Class or Test::Class::Moose where all tests are run in
84               methods and you want to track what test method does the
85               touching. Please note that this level of coverage tracking is
86               not automatic.
87
88           event => $event
89               The full event being processed.
90
91   PUBLIC API
92       $agg->process_event($event)
93           Process the event, aggregating any coverage info it may contain.
94
95       $touched = $add->touched()
96           Returns the following structure, which tells you how many times a
97           specific source file's subroutines were called. There are also
98           "special" subroutines '<>' and '*' which mean "file was opened via
99           open" and "code outside of a subroutine".
100
101               {
102                   source_file => {
103                       source_method => $touched_count,
104                       ...
105                   },
106                   ...
107               }
108
109       $metrics = $agg->build_metrics()
110       $metrics = $agg->build_metrics(exclude_private => $BOOL)
111           Will build metrics, and include them in the output from
112           "$agg->coverage()" next time it is called.
113
114           The "exclude_private" option, when set to true, will exclude any
115           method that beings with an underscore from the coverage metrics and
116           untested sub list.
117
118           Metrics:
119
120               {
121                   files => {total => 20, tested => 18},
122                   subs  => {total => 80, tested => 70},
123
124                   untested => {
125                       files => \@file_list,
126                       subs => {
127                           file => \@sub_list,
128                           ...
129                       }
130                   },
131               }
132

SOURCE

134       The source code repository for Test2-Harness can be found at
135       http://github.com/Test-More/Test2-Harness/.
136

MAINTAINERS

138       Chad Granum <exodist@cpan.org>
139

AUTHORS

141       Chad Granum <exodist@cpan.org>
142
144       Copyright 2020 Chad Granum <exodist7@gmail.com>.
145
146       This program is free software; you can redistribute it and/or modify it
147       under the same terms as Perl itself.
148
149       See http://dev.perl.org/licenses/
150
151
152
153perl v5.34.1                      202T2e-s0t72-:1:1Harness::Log::CoverageAggregator(3)
Impressum