Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Consider this test file:

#!perl use Test::More 0.96; subtest "subtest1" => sub { ok 1; ok 2; }; subtest "subtest2" => sub { ok 3; ok 4; ok 5; subtest "subtest3" => sub { ok 6; ok 7; }; }; done_testing;

If we run it:

% prove -lv t/sample.t 
t/sample.t .. 
    # Subtest: subtest1
    ok 1
    ok 2
    1..2
ok 1 - subtest1
    # Subtest: subtest2
    ok 1
    ok 2
    ok 3
        # Subtest: subtest3
        ok 1
        ok 2
        1..2
    ok 4 - subtest3
    1..4
ok 2 - subtest2
1..2
ok
All tests successful.
Files=1, Tests=2,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.01 cusr  0.00 csys =  0.03 CPU)
Result: PASS

Is there a way to get the number of tests including those inside subtests? (in this case, 7, or 8 if we include the inner subtests, or 10 if we include all subtests). Since I group tests using subtests, I keep seeing a low number of tests (in this case, 2) even though I have added more and more tests.

Replies are listed 'Best First'.
Re: Printing number of tests (including inside subtests) ( --formatter TAP::Parser::Formatter)
by Anonymous Monk on Jan 03, 2014 at 12:00 UTC

    It looks like its possible (if you look at sub Test::More::subtest and sub Test::Harness::runtests )

    you need prove --formatter with TAP::Parser::Formatter subclass (or actually TAP::Formatter::Base, as "TAP::Parser::Formatter " appears to be typo in prove documentation )

      Patch submitted. I will withdraw mine if the AM wishes to take credit.

      --MidLifeXis