The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

TAPx::Parser::Aggregator - Aggregate TAPx::Parser results.

VERSION

Version 0.50_01

SYNOPSIS

    use TAPx::Parser::Aggregator;

    my $aggregate = TAPx::Parser::Aggregator->new;
    $aggregate->add( 't/00-load.t', $load_parser );
    $aggregate->add( 't/10-lex.t',  $lex_parser  );
    
    my $summary = <<'END_SUMMARY';
    Passed:  %s
    Failed:  %s
    Unexpectedly succeeded: %s
    END_SUMMARY
    printf $summary, 
           scalar $aggregate->passed, 
           scalar $aggregate->failed,
           scalar $aggregate->todo_failed;

DESCRIPTION

TAPx::Parser::Aggregator is a simple class which takes parser objects and allows reporting of aggregate results.

METHODS

Class methods

new

 my $aggregate = TAPx::Parser::Aggregator->new;

Returns a new TAPx::Parser::Aggregator object.

Instance methods

add

  $aggregate->add( $description, $parser );

Takes two arguments, the description of the TAP source (usually a test file name, but it doesn't have to be) and a TAPx::Parser object.

Trying to reuse a description is a fatal error.

parsers

  my $count   = $aggregate->parsers;
  my @parsers = $aggregate->parsers;
  my @parsers = $aggregate->parsers(@descriptions);

In scalar context without arguments, this method returns the number of parsers aggregated. In list context without arguments, returns the parsers in the order they were added.

If arguments are used, these should be a list of descriptions used with the add method. Returns an array in list context or an array reference in scalar context. The array contents will the requested parsers in the order they were listed in the argument list.

Passing in an unknown description is a fatal error.

Summary methods

Each of the following methods will return the total number of corresponding tests if called in scalar context. If called in list context, returns the descriptions of the parsers which contain the corresponding tests (see add for an explanation of description.

  • failed

  • parse_errors

  • passed

  • skipped

  • todo

  • todo_failed

For example, to find out how many tests unexpectedly succeeded (TODO tests which passed when they shouldn't):

 my $count        = $aggregate->todo_failed;
 my @descriptions = $aggregate->todo_failed;

total

  my $tests_run = $aggregate->total;

Returns the total number of tests run.