http://qs321.pair.com?node_id=1199051


in reply to Print summary of tests results when using Test::More ?

I'm not seeing anyway to do this within the module

choroba and 1nickt already pointed you to prove, which I think is the best answer, but just to answer this part of the question, yes, there are ways to get at the test results from within the test script itself, although that isn't really how the test architecture works - test scripts generate TAP output which is then consumed by harnesses to generate the statistics etc. across multiple test files.

If tests in an individual script fail, you already get an output like "# Looks like you failed 5 tests of 30." at the end of the test script. To get at this information yourself, Test::More->builder->details returns a list of hashes that you can inspect yourself (see Test::Builder):

my ($passed,$failed) = (0,0); my @tests = Test::More->builder->details; for my $test (@tests) { if ($test->{ok}) {$passed++} else {$failed++}; } diag "Of ".(0+@tests)." tests, $passed passed and $failed failed.";

Now AFAIK and as far as I can tell from looking at the source, what prove does is use TAP::Harness, which in turn uses TAP::Parser and TAP::Formatter::Base to generate the summary output. But again, it's much easier to just use prove.