![]() |
|
XP is just a number | |
PerlMonks |
Re^3: perl script testingby pemungkah (Priest) |
on Dec 10, 2013 at 23:00 UTC ( #1066517=note: print w/replies, xml ) | Need Help?? |
This is a skeleton of your application to be:
The "Main program here" section is going to be the code that basically reads the command line options, figures out what to do, and then calls the other subs or methods to make it happen. The "rest of implementation here" is simply placeholder text to indicate where you'd put the code that actually implements getting things done - that is the code your tests would be testing. The "__PACKAGE__..." line is what makes this .pm file into an executable program; it says "if caller() doesn' return anything (that is, we haven't been loaded by someone else as a module), execute this package's run() method." Here's a contrived example. Now in you tests, you can do stuff like this: (Note that I have not tested this; it is simply meant to be an illustration of technique.) You package has subs that can be tested now to see if they do what they are supposed to. I hope this points you toward a workable direction. Edit: Not sure why this is getting down voted - would someone care to comment? Do you disagree with the technique? Do you feel I should have solved the problem more completely? Actual feedback is more useful.
In Section
Seekers of Perl Wisdom
|
|