Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Needing help on testing

by pryrt (Prior)
on Oct 29, 2018 at 21:57 UTC ( #1224889=note: print w/replies, xml ) Need Help??

in reply to Needing help on testing

For testing any functions in your files, I believe you should be able to create a test script which has use lib '.'; use ''; -- anything that's automatically run in your code will, I think, be thrown away (unless the return code is not TRUE -- in which case, the use '' will fail). If there's too much user-interface (prompting for inputs, etc), I don't know how successful the use will be. But assuming it gets past that point, you can then test the functions from in the same way you would test functions from modules. And you can then eventually move those functions into modules.

Alternatively, you could create a new module (for appropriate package names, and directory hierarchy), and add the line use newmod; to Then, one by one, move functions out of the into; with each function this_fn() that you move, make sure still runs as it used to (with a quick manual test) to make sure it wasn't using a file-lexical that it shouldn't be, and write up the appropriate t/*.t test suite for the function that's moved into (Often times, you can make the this_fn.t look very similar to calls from your original Continue this process until the just contains the script, and all the functions are moved to modules where they can be easily tested.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1224889]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2019-10-18 10:53 GMT
Find Nodes?
    Voting Booth?