|
|
|
Clear questions and runnable code get the best and fastest answer |
|
| PerlMonks |
Re: Looking for help for unit tests and code coverage on an existing perl script (modulino References)by eyepopslikeamosquito (Archbishop) |
| on Feb 01, 2014 at 09:55 UTC ( [id://1072954]=note: print w/replies, xml ) | Need Help?? |
|
I would extract a module from your script and unit test the module directly via Test::More and the prove command. I like to keep my script mainlines as short as is practicable, with all the heavy lifting done in (unit-tested) module/s. There are many examples of this general approach on the CPAN; see, for example, the perltidy command, part of the Perl-Tidy distribution and the perlcritic command, part of the Perl-Critic distribution. As an alternative, and perhaps a bit less work, you could re-structure your script as a "modulino", that is, a script that can masquerade as a module for ease of testing. This approach is described at:
... though modulinos are too sneaky/clever for my tastes ("scripts should use modules, not pretend to be modules"). References Added Later
PM Nodes:
Updated: Many extra references were added long after the original reply was made.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||