Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

For testing any functions in your codebase.pl files, I believe you should be able to create a test script which has use lib '.'; use 'codebase.pl'; -- 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 'codebase.pl' 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 codebase.pl 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 newmod.pm (for appropriate package names, and directory hierarchy), and add the line use newmod; to codebase.pl. Then, one by one, move functions out of the codebase.pl into newmod.pm; with each function this_fn() that you move, make sure codebase.pl 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 newmod.pm. (Often times, you can make the this_fn.t look very similar to calls from your original codebase.pl). Continue this process until the codebase.pl just contains the script, and all the functions are moved to modules where they can be easily tested.


In reply to Re: Needing help on testing by pryrt
in thread Needing help on testing by Zenzizenzizenzic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (5)
    As of 2019-10-16 06:44 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?