Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Test::More - Skip following tests if one test fails

by tobyink (Abbot)
on Feb 28, 2013 at 12:27 UTC ( #1021048=note: print w/replies, xml ) Need Help??

in reply to Test::More - Skip following tests if one test fails

Take advantage of the fact that Test::More's ok, like, is, etc functions all return a boolean indicating the test's status.

The two possibilities you should look at are:

If when a test fails, you want to skip *all* the remaining tests in the file do:

like(...) or BAIL_OUT("No point in continuing");

If you just wish to skip three tests and then continue with some more tests in the file:

SKIP: { like(...) or skip "The next three are irrelevant", 3; # the three tests to be skipped here. ok(...); ok(...); ok(...); } # will continue with this test ok(...);
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: Test::More - Skip following tests if one test fails
by Doozer (Scribe) on Feb 28, 2013 at 12:49 UTC
    Thank you both for the responses, they are very helpful. I had a feeling I was over complicating what the instructions were saying. Your examples have made it very clear how to use the SKIP functionality and I have got it working how I need.

    Thanks again!

Re^2: Test::More - Skip following tests if one test fails
by Edster (Initiate) on May 27, 2014 at 13:29 UTC

    Just an additional note (many months after the event, and frankly to help me remember if I search for this again), BAIL_OUT will not work in the same way as SKIP - it will cause the test to fail.

    If your uber condition is not something that should cause a test failure, you'll probably want to use tobyink's SKIP: arrangement or Ken's skip_all => $skip_reason below.

      Worse, BAIL_OUT will cause subsequent test scripts to not be run! Though nobody seems to get that impression from reading the documentation, IME.

      - tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1021048]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2018-05-25 00:16 GMT
Find Nodes?
    Voting Booth?