I am in the midst of refactoring a large application into several modules, on the theory that it will make it easier to package the application for use in different places if it is modularized.

One of the modules provides a frontend to Net::Telnet::Cisco to slurp up various tables from routers and switches. To do so it must log in to each router or switch using its telnet and enable passwords.

My question is: given the fact that it is problematic to do anything that prompts the user in a t/*.t script, and it is even more problematic to ask for the user to put passwords on the command line or in the environment (which in "make test" is often done from the command line anyway), how can I test these modules at all?

Net::Telnet::Cisco itself seems to get around the issue by using only a test.pl script (which doesn't have the same issues as a t/*.t script WRT the test harness eating the prompt). Can a given module use *both* test.pl and t/*.t?

As you can probably tell, I'm new to the Monastery and fairly new at writing modules as opposed to scripts. Any assistance will be appreciated. Thanks.


In reply to Module testing using passwords by bigmacbear

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, details, 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, summary, 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.