| Test2::Harness::Log::CoverageAggregator(3pm) | User Contributed Perl Documentation | Test2::Harness::Log::CoverageAggregator(3pm) |
Test2::Harness::Log::CoverageAggregator - Module for aggregating coverage data from a stream of events.
This module takes a stream of events and produces aggregated coverage data.
use Test2::Harness::Log::CoverageAggregator;
my $agg = Test2::Harness::Log::CoverageAggregator->new();
while (my $e = $log->next_event) {
$agg->process_event($e);
}
# Get a structure like { source_file => { source_method => $touched_count, ... }, ...}
my $touched_source = $agg->touched;
# Get a structure like
# {
# files => {total => 5, tested => 2},
# subs => {total => 20, tested => 12},
# untested => {files => \@file_list, subs => {file => \@sub_list, ...}},
# }
my $metrics = $agg->metrics;
If you implement these in a subclass they will be called for you at the proper times, making subclassing much easier. In most cases you can avoid overriding process_event().
Note: If a test is run more than once (re-run) it will start and stop again for each re-run. The event is also provided as an argument so that you can check for a try-id or similar in the event that re-runs matter to you.
Note: If a test is run more than once (re-run) it will start and stop again for each re-run. The event is also provided as an argument so that you can check for a try-id or similar in the event that re-runs matter to you.
In most cases you probably want to leave this unimplemented and implement the "touch()" method instead of iterating over the coverage structure yourself.
{
source_file => {
source_method => $touched_count,
...
},
...
}
The "exclude_private" option, when set to true, will exclude any method that beings with an underscore from the coverage metrics and untested sub list.
Metrics:
{
files => {total => 20, tested => 18},
subs => {total => 80, tested => 70},
untested => {
files => \@file_list,
subs => {
file => \@sub_list,
...
}
},
}
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 |