On Tue, Feb 03, 2009 at 08:21:33PM -0800, Michael G Schwern wrote:
>
> Finally, this makes it now possible to build up the test plan as you go. I'd
> like to put first order support into Test::Builder and Test::More for it, but
> for the moment this will work:
>
> use Test::More;
>
> my $tests = 2;
> pass;
> pass;
>
> $tests += 1;
> pass;
>
> done_testing($tests);
Just a side note: this has always been possible, as I've seen people do the
following:
my $tests;
use Test::More tests => $tests;
BEGIN { $tests += 2 };
ok( ... );
ok( ... );
BEGIN { $tests += 1 };
ok( ... );
I like the plan add => $n interface a lot, especially with DrHyde's
suggestion to use it for optional tests. That may look better than
skipped tests, but I guess it's mostly a difference in the message one
wants to send: skipped tests include a reason why tests were skipped.
It may also make the plan computation much easier for complicated test
suites where one tests a list of cases with a varying number of tests
for each case, and doesn't want to put the hairy computation in a map {}
at the plan() stage. Now that I think about it, this latter case is
probably a better use case for plan add.
--
Philippe Bruhat (BooK)
When you open a new door, the bad comes in with the good.
(Moral from Groo The Wanderer #102 (Epic))