We don't bite newbies here... much | |
PerlMonks |
testing a standalone script with parametersby chexmix (Hermit) |
on Mar 03, 2009 at 19:58 UTC ( [id://747874]=perlquestion: print w/replies, xml ) | Need Help?? |
chexmix has asked for the wisdom of the Perl Monks concerning the following question:
Good afternoon, Monks -
I am trying to put together my first-ever test of a standalone script. I've been looking at the last chapter of the O'Reilly Perl Testing: A Developer's Notebook as well as some of the standard testing documentation (Test::Tutorial, etc). However, though I've gotten a start, I'm not sure where to go from here. The script to be tested expects two parameters, the name of an input file and the name of an output file (so it is a filter, in a way). As Perl Testing suggests I have added the following line to the script: main( @ARGV ) unless caller( ); ... and recast the first part of the program as a sub called main. I then created a test script that looks like this:
When I run this against the script 'myScript', I get the following output:
... which is fine, but what I'd like to do is set up some tests which confirm that the script is doing its thing correctly, e.g. tests that a dummy file (provided as part of the testing suite or created by an intermediate script) passed to the script correctly creates a dummy output file, or what have you. So really the question is how, in that testing script, do I go about passing in those parameters to the main() routine in myScript? In the main() routine, input and output params are coded as $param{files} and $param{output}, respectively, e.g. with Getopt::Long. Thanks in advance for any pointers, or pointers to tutorials that have more info on testing standalone scripts. GB
Back to
Seekers of Perl Wisdom
|
|