Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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


Comment on Re: Test::More - Skip following tests if one test fails
Select or Download Code
Re^2: Test::More - Skip following tests if one test fails
by Doozer (Beadle) 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2014-10-31 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (217 votes), past polls