Hello monkses,

I'm currently finishing off a module I plan to release on CPAN. It would be beneficial if the test suite included tests against a live server (simulated tests are also included, but not as good as the real thing). For this I need to prompt the user for some information, to see whether he has such a server available and what it's address etc. are.

I gather that putting interactivity into the general test suite is a big no-no (it breaks the automated smoke tests for one), so I've been thinking about how I could do this and come up with the following:

use Test::More qw(no_plan); use strict; use warnings; SKIP: { skip qq(Won't run automatically, execute "export MyModOPTRUN=yes" +to enable interactive test) unless ($ENV{MyModOPTRUN} && $ENV{MyModOPTRUN} eq "yes"); warn "\nEnter your innermost secret:\n"; my $secret = (<STDIN>); ok ($secret,"Yep, that's it"); }

Obviously replacing "MyMod" with the actual name of my module. This will produce

t/02.optional....ok 1/1 skipped: Not running automatically, execute "export MyModO +PTRUN=yes" to enable interactive test All tests successful, 1 subtest skipped. Files=1, Tests=1, 0 wallclock secs ( 0.00 cusr + 0.01 csys = 0.01 C +PU)

When run without the environment variable set, which should be all right I think.

Are there any problems with this approach? Does the "export" syntax even work on non-*NIX-shells? If not, is there an equivalent (I can test for $^O and adjust the skip message accordingly)? Is there a better way to do this?

Thanks in advance


All dogma is stupid.

In reply to Interactivity in tests - done correctly? by tirwhan

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.