in reply to Re: No plan "weakens" my Test scripts?
in thread No plan "weakens" my Test scripts?

In situations like that described, the idea is that your test script should *count* the number of records in the file (before running any tests), and then call plan(). Let's say your test script has 10 regular tests, plus it wants to run one test per line in somefile.txt. You'd use something like this:
use Test::More; ## NB *not* no_plan open(FOO,"<somefile.txt") or die "Can't open test file: $!" my $a = 0; $a++ while (<FOO>); close(FOO); plan tests => 10 + $a;

Replies are listed 'Best First'.
Re^3: No plan "weakens" my Test scripts?
by Anonymous Monk on Feb 08, 2005 at 12:20 UTC
    Or just:
    use Test::More; open my $foo, "<", "somefile.txt" or die; () = <$foo>; plan tests => 10 + $.;
    And if your tests aren't going to run on systems that don't have wc:
    {no warnings; use Test::More plan => 10 + `wc -l "somefile.txt"`}