Test::Flatten - subtest output to a flatten
in t/foo.t
use Test::More; use Test::Flatten; subtest 'foo' => sub { pass 'OK'; }; subtest 'bar' => sub { pass 'ok'; subtest 'baz' => sub { pass 'ok'; }; }; done_testing;
run it
$ prove -lvc t/foo.t t/foo.t .. # ------------------------------------------------------------------------------ # foo # ------------------------------------------------------------------------------ ok 1 - ok # ------------------------------------------------------------------------------ # bar # ------------------------------------------------------------------------------ ok 2 - ok # ------------------------------------------------------------------------------ # baz # ------------------------------------------------------------------------------ ok 3 - ok 1..3 ok
oh, flatten!
Test::Flatten is override Test::More::subtest.
The subtest I think there are some problems.
use Test::More; subtest 'foo' => sub { pass 'ok'; }; done_testing; # ok 1 - foo is end of subtest block. t/foo.t .. ok 1 - ok 1..1 ok 1 - foo 1..1 ok
I want FIRST.
use Test::More; subtest 'foo' => sub { pass 'bar'; pass 'baz'; }; done_testing; # total tests is 1 t/foo.t .. ok 1 - bar ok 2 - baz 1..2 ok 1 - foo 1..1
I want 2.
use Test::More; subtest 'foo' => sub { pass 'parent one'; pass 'parent two'; my $pid = fork; unless ($pid) { pass 'child one'; pass 'child two'; fail 'child three'; exit; } wait; pass 'parent three'; }; done_testing; # success...? t/foo.t .. ok 1 - parent one ok 2 - parent two ok 3 - child one ok 4 - child two not ok 5 - child three # Failed test 'child three' # at t/foo.t line 13. ok 3 - parent three 1..3 ok 1 - foo 1..1 ok
oh, really? I want FAIL and sync count.
Yes, We can!!
subtest($name, \&code)
This like Test::More::subtest.
If you need, you can using SUBTEST_FILTER environment. This is just a *hack* to skip only blocks matched the block name by environment variable. SUBTEST_FILTER variable can use regexp
SUBTEST_FILTER
$ env SUBTEST_FILTER=foo prove -lvc t/bar.t # SKIP: bar by SUBTEST_FILTER # ------------------------------------------------------------------------------ # foo # ------------------------------------------------------------------------------ ok 1 - passed # SKIP: baz by SUBTEST_FILTER 1..1
xaicron <xaicron {at} cpan.org>
Copyright 2011 - xaicron
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Test::SharedFork
To install Test::Flatten, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Flatten
CPAN shell
perl -MCPAN -e shell install Test::Flatten
For more information on module installation, please visit the detailed CPAN module installation guide.