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

Re: Passing Dynamic Value to Test::More tests

by chromatic (Archbishop)
on Jan 19, 2006 at 06:48 UTC ( #524144=note: print w/replies, xml ) Need Help??

in reply to Passing Dynamic Value to Test::More tests

An alternate approach is:

# compile time use Test::More; # run time my $test_count = 2; plan( tests => $test_count );

You can use this when you don't have tests that execute in BEGIN, CHECK, or INIT blocks.

Replies are listed 'Best First'.
Re^2: Passing Dynamic Value to Test::More tests
by xdg (Monsignor) on Jan 19, 2006 at 12:10 UTC

    That's a great point. I use that pattern also for when I may want to skip a test file entirely if a test dependency isn't available.

    use Test::More; eval { require Some::Crazy::Dependency }; if ($@) { plan skip_all => "Some::Crazy::Dependency not available"; } else { plan tests => 42; }

    It could be done in a BEGIN block, too, but I find it more readable without them.


    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2022-05-24 03:42 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (82 votes). Check out past polls.