elTriberium has asked for the wisdom of the Perl Monks concerning the following question:
Test 1 obviously fails, so I want it to exit the test immediately. But it still executes the subroutine of the 2nd test before exiting. Here is the program output:#!/usr/bin/perl use Test::Most tests => 3; die_on_fail; ok(1==2, "checkpoint 1"); lives_ok ( sub { print "checkpoint 2\n"; }, "lives_ok test" ); ok(1==1, "checkpoint 3");
It doesn't execute test 3, so die_on_fail is working, but it still enters the subroutine of test 2. Is there any way to keep it from running the subroutine if test 1 failed? I can of course always manually enter "|| or die" after each test, but I would prefer something automated like the "die_on_fail" option.-bash:perl$ perl dieonfail.pl 1..3 not ok 1 - checkpoint 1 # Failed test 'checkpoint 1' # at dieonfail.pl line 6. checkpoint 2 Test failed. Stopping test. # Looks like you planned 3 tests but only ran 1. # Looks like you failed 1 test of 1 run. # Looks like your test died just after 1.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: die_on_fail of Test::Most only dies after the next test
by ELISHEVA (Prior) on May 21, 2009 at 21:41 UTC | |
by elTriberium (Friar) on May 21, 2009 at 22:30 UTC |