in reply to Looking for help for unit tests and code coverage on an existing perl script
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Looking for help for unit tests and code coverage on an existing perl script
by tizatron (Novice) on Feb 03, 2014 at 23:22 UTC |