Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Print summary of tests results when using Test::More ?

by haukex (Bishop)
on Sep 10, 2017 at 21:25 UTC ( #1199051=note: print w/replies, xml ) Need Help??


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.

Replies are listed 'Best First'.
Re^2: Print summary of tests results when using Test::More ?
by perl4life (Initiate) on Sep 10, 2017 at 22:21 UTC
    thank you all for the replies!

    no I had no idea about prove, I do now see there's one small mention of it in 'other components' in the test::more doc.

    prove is exactly what i needed thank you again.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199051]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2020-09-26 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (141 votes). Check out past polls.

    Notices?