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); } my $coverage = $agg->coverage; use Test2::Harness::Util::JSON qw/encode_json/; open(my $fh, '>', "coverage.json") or die "$!"; print $fh encode_json($coverage); close($fh);
Process the event, aggregating any coverage info it may contain.
Will build metrics, and include them in the output from $agg->coverage() next time it is called.
$agg->coverage()
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.
exclude_private
Metrics:
{ files => {total => 20, tested => 18}, subs => {total => 80, tested => 70}, }
Produce a hashref of all aggregated coverage data:
{ files => { 'test_file_a.t' => [ 'lib/MyModule1.pm', 'lib/MyModule2.pm', ..., ], 'test_file_b.t' => [ 'share/css/foo.css', 'lib/AnotherModule.pm', ... ], ..., }, testmeta => { 'test_file_a.t' => {...}, }, # If you called ->build_metrics this will also be present metrics => { files => {total => 20, tested => 18}, subs => {total => 80, tested => 70}, }, # If you called ->build_metrics this will also be present untested => { files => ['lib/untested.pm', ...], subs => { 'lib/untested.pm' => [ 'foo', 'bar', ... ], ..., }, }, }
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/
To install Test2::Harness, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test2::Harness
CPAN shell
perl -MCPAN -e shell install Test2::Harness
For more information on module installation, please visit the detailed CPAN module installation guide.