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.


In reply to Re: Print summary of tests results when using Test::More ? by haukex
in thread Print summary of tests results when using Test::More ? by perl4life

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.