in reply to Counting test cases

Interesting post. The problem I'm trying (not very hard) to solve is a non-fatal test that just tries all of the links on a given page. I don't know how many links there are, and I don't really care -- I just want to find out which links work and which links fail.

However, it seems that Test::More wants to know at compile time how many tests there are, and I only know how many links there are to test at run time.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re^2: Counting test cases
by kyle (Abbot) on Apr 01, 2008 at 16:02 UTC

    The solution is hiding in the OP. I'll spell it out...

    use Test::More; # note I don't say how many there are # do what you have to do to get your list of links my @links = list_of_links(); # this happens at run time plan 'tests' => scalar @links; foreach my $link ( @links ) { ok( link_success( $link ), "link '$link' is good" ); }

    You can call Test::More::plan any time before you do the first test, and you can do as much test setup as you want before that.