Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Should a CPAN module list Test:: modules as dependencies?

by Corion (Patriarch)
on Jul 20, 2004 at 13:32 UTC ( [id://375907]=note: print w/replies, xml ) Need Help??


in reply to Should a CPAN module list Test:: modules as dependencies?

Personally, I prefer to use Test::Mores skip feature to skip tests whenever a optional (in general) but prerequisite (for the test) module is unavailable:

use strict; use Test::More tests => 5; my $have_test_deep; BEGIN { eval { require Test::Deep; Test::Deep->import(Some => 'Parameters'); $have_test_deep = 1; }; }; SKIP: { skip "Need Test::Deep for the tests", 5 unless $have_test_deep; ok("I'm OK"); ok("You're OK"); ok("We're OK"); ok("They're OK"); ok("All's OK"); };

The Test::More documentation lists a different idiom of placing the prerequisite test in the SKIP block instead of the top of the test script:

SKIP: { eval { require HTML::Lint }; skip "HTML::Lint not installed", 2 if $@; my $lint = new HTML::Lint; isa_ok( $lint, "HTML::Lint" ); $lint->parse( $html ); is( $lint->errors, 0, "No errors found in HTML" ); }

Updated: Fixed code in my example, added example from Test::More documentation

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (None)
    As of 2024-04-25 04:00 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found