Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Run certain tests automatically using Test::Class

by marinersk (Priest)
on Apr 02, 2014 at 21:38 UTC ( [id://1080840]=note: print w/replies, xml ) Need Help??


in reply to Run certain tests automatically using Test::Class

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>

Replies are listed 'Best First'.
Re^2: Run certain tests automatically using Test::Class
by moez507 (Novice) on Apr 03, 2014 at 15:37 UTC
    Thank You ! Its a very good idea.

    However, I was looking for some sort of template system , or some way that the 'test' runs automatically. Such that the programmer does not have to remember to add it in for each test.

    Perhaps , its a tall order?

    Thanks,
    Moez.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-24 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found