Perl 5 version 18.0 documentation



TAP::Parser::Aggregator - Aggregate TAP::Parser results


Version 3.26


  1. use TAP::Parser::Aggregator;
  2. my $aggregate = TAP::Parser::Aggregator->new;
  3. $aggregate->add( 't/00-load.t', $load_parser );
  4. $aggregate->add( 't/10-lex.t', $lex_parser );
  5. my $summary = <<'END_SUMMARY';
  6. Passed: %s
  7. Failed: %s
  8. Unexpectedly succeeded: %s
  10. printf $summary,
  11. scalar $aggregate->passed,
  12. scalar $aggregate->failed,
  13. scalar $aggregate->todo_passed;


TAP::Parser::Aggregator collects parser objects and allows reporting/querying their aggregate results.


Class Methods


  1. my $aggregate = TAP::Parser::Aggregator->new;

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

Instance Methods


  1. $aggregate->add( $description => $parser );

The $description is usually a test file name (but only by convention.) It is used as a unique identifier (see e.g. parsers.) Reusing a description is a fatal error.

The $parser is a TAP::Parser object.


  1. my $count = $aggregate->parsers;
  2. my @parsers = $aggregate->parsers;
  3. 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 @descriptions is given, these correspond to the keys used in each call to the add() method. Returns an array of the requested parsers (in the requested order) in list context or an array reference in scalar context.

Requesting an unknown identifier is a fatal error.


Get an array of descriptions in the order in which they were added to the aggregator.


Call start immediately before adding any results to the aggregator. Among other times it records the start time for the test run.


Call stop immediately after adding all test results to the aggregator.


Elapsed returns a Benchmark object that represents the running time of the aggregated tests. In order for elapsed to be valid you must call start before running the tests and stop immediately afterwards.


Returns a formatted string representing the runtime returned by elapsed() . This lets the caller not worry about Benchmark.


Return true if all the tests passed and no parse errors were detected.


Get a single word describing the status of the aggregated tests. Depending on the outcome of the tests returns 'PASS', 'FAIL' or 'NOTESTS'. This token is understood by CPAN::Reporter.

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
  • planned
  • skipped
  • todo
  • todo_passed
  • wait
  • exit

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

  1. my $count = $aggregate->todo_passed;
  2. my @descriptions = $aggregate->todo_passed;

Note that wait and exit are the totals of the wait and exit statuses of each of the tests. These values are totalled only to provide a true value if any of them are non-zero.


  1. my $tests_run = $aggregate->total;

Returns the total number of tests run.


  1. if ( $parser->has_problems ) {
  2. ...
  3. }

Identical to has_errors , but also returns true if any TODO tests unexpectedly succeeded. This is more akin to "warnings".


  1. if ( $parser->has_errors ) {
  2. ...
  3. }

Returns true if any of the parsers failed. This includes:

  • Failed tests
  • Parse errors
  • Bad exit or wait status


  1. # deprecated in favor of 'todo_passed'. This method was horribly misnamed.


See Also