I'm wondering the way to test each Subroutings in *.pl files individually. But Can't use 'require' clause because some *.pl requires Arguments.
for example
use Test::More;
require "some.pl"
will always fail Test at 'require'.
because "some.pl " required a argument and end with
exit(0);
of the file.
I just want to test "Func1,usage,...whatever," every subroutings in '*.pl' individually.
some.pl is like that
my ( $cmd) = @ARGV;
if (!defined $cmd ) {
usage();
} else {
&Func1;
}
exit(0);
sub Func1 {
print "hello";
}
sub usage {
print "Usage:\n",
}
How can I write a test code for "sub Func1" by "Test::More"?
Any suggestions appreciate.
To exercise a standalone script that you expect to exit, run it with
system. Capture the output and inspect it at the end of thesystemcall.