note
haukex
<blockquote><i>I'm not seeing anyway to do this within the module</i></blockquote>
<p>[choroba] and [1nickt] already pointed you to [doc://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 [https://testanything.org/|TAP] output which is then consumed by harnesses to generate the statistics etc. across multiple test files.</p>
<p>If tests in an individual script fail, you already get an output like "<c># Looks like you failed 5 tests of 30.</c>" at the end of the test script. To get at this information yourself, <c>Test::More->builder->details</c> returns a list of hashes that you can inspect yourself (see [doc://Test::Builder]):</p>
<c>
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.";
</c>
<p>Now AFAIK and as far as I can tell from looking at the source, what [doc://prove] does is use [doc://TAP::Harness], which in turn uses [doc://TAP::Parser] and [doc://TAP::Formatter::Base] to generate the summary output. But again, it's much easier to just use [doc://prove].</p>
1199046
1199046