![]() |
Test harness for scripts?
When creating Perl modules, there is Test::More and similar tools
available to automate the testing. Are there general guidelines for writing test scripts that work with the Test::Harness framework? I noticed Test::Script - it offers one function - "script_compiles_ok()" But if I need more - what are some good practices for testing the full script: 1) run script with --arg1 --arg2, check that STDOUT has a line with "text line 1" 2) run script with --arg3 file, check that file was created (and then clean up - remove it) 3) run script with --arg4, check that Unknown Arg error is thrown One option is just to write the perl code to execute the above commands, and do the checks. But how to run the command - "make test" puts the script in blib/script, the script itself is in bin/, and there may be a system installed old script version, so need to make sure that the test is running the script from the development folder. Any suggestions? |
Re: Test harness for scripts?
<bwooster47@gmail.com> wrote in message news:1179344869.181841.195250@o5g2000hsb.googlegro ups.com... > When creating Perl modules, there is Test::More and similar tools > available to automate the testing. > > Are there general guidelines for writing test scripts that work with > the Test::Harness framework? Any file with a '.t' extension that's placed in the './t' folder will be automatically run by 'make test'. There are other options, too, but that's how most people create their test scripts. .. .. > But how to run the command - "make test" > puts the script in blib/script, the script itself is in bin/, and > there may be a system installed old script version, so need to make > sure that the test is running the script from the development folder. > I don't think this is a consideration at all. The test scripts themselves (ie the '.t' scripts in the './t' folder) don't get put into blib - they stay where they are. Also, 'make test' will find (and use) the files in blib *before* it goes looking for files (in @INC) that have been installed into perl as a result of an earlier build. (That is, if the file exists in blib, then that's the one that 'make test' is going to use.) Cheers, Rob |
| All times are GMT. The time now is 07:46 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.