Would it not be simpler to simply set an environment variable in the test environment, and let its absence serve as a flag to the tests themselves to voluntarily exit?

Simply make sure every test method first does this -- or calls a method designed to do this -- and the tests will govern themselves.

#!/usr/bin/perl use strict; use warnings; my $TestFlag = $ENV{'TEST_ENVIRONMENT'}; if (!defined $TestFlag) { $TestFlag = ''; } if ($TestFlag =~ /TRUE/i) { print "I'm running tests! I'm running tests!\n"; } else { print "This does not appear to be a test environment. Skipping te +sts.\n"; } exit; __END__ S:\Steve\Dev\PerlMonks\P-2014-04-02@1516-Self-Governing-Tests>set TEST +_ENVIRONMENT=TRUE S:\Steve\Dev\PerlMonks\P-2014-04-02@1516-Self-Governing-Tests>perl may +betest.pl I'm running tests! I'm running tests! S:\Steve\Dev\PerlMonks\P-2014-04-02@1516-Self-Governing-Tests>set TEST +_ENVIRONMENT= S:\Steve\Dev\PerlMonks\P-2014-04-02@1516-Self-Governing-Tests>perl may +betest.pl This does not appear to be a test environment. Skipping tests. S:\Steve\Dev\PerlMonks\P-2014-04-02@1516-Self-Governing-Tests>

In reply to Re: Run certain tests automatically using Test::Class by marinersk
in thread Run certain tests automatically using Test::Class by moez507

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.