good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: TDD of non-module codeby chrestomanci (Priest) |
on Jan 24, 2012 at 13:03 UTC ( [id://949677]=note: print w/replies, xml ) | Need Help?? |
That sounds like a sensible idea. You could add a --self-test command line switch, and have it on by default during development, and off when the code is complete. You could even put the test code into a separate .pm file (in the same package) so that you don't have to ship the test code in your deliverable. An alternative approach would be to create a .t test script that loads and executes your main program, either using system() with a test command line, and then examines the output, or by loading the whole script into a scalar string, and using eval() Overall though I think it is wiser in the long term to take moritz's advice and make your script act as both standalone and as a module with doit(@ARGV) unless caller; at the end of all your subroutine definitions
In Section
Seekers of Perl Wisdom
|
|