# The following was supposedly scribed by
# Ofer Nave
# on Monday 28 February 2005 07:50 pm:
Incidentally, I sorta picked a tough module to start learning how to
write tests for. Does anyone have advice on how to write tests for my
Parallel::Simple module?
I was just thinking of writing some tests for Getopt::Helpful and was
wondering if something using IPC::Run might do the trick. The idea was
to write a series of little programs that should behave in a given way
(print something, die, or warn with a usage message) for some set of
arguments and doing a string-match against their outputs.
This is really an ill-formed idea right now but:
($stdout, $stderr, $code) = run_prog($prog, '--arg' , 'val');
ok($stdout eq arg - val);
($stdout, $stderr, $code) = run_prog($prog, '--nonarg' , 'val');
ok($code == 1); # error code (as expected)
($stdout, $stderr, $code) = run_prog($prog, '--help' , 'arg');
ok($stderr =~ m/arg/); # help messages on stderr
I'm not sure if there's a test module that already does this or not.
Any suggestions? (maybe Test::Cmd))
--Eric
--
Politics is not a bad profession. If you succeed there are many
rewards, if you disgrace yourself you can always write a book.
-- Ronald Reagan
-
http://scratchcomputing.com
-