Hi all, I don't know if this a bug or a feature but die_on_fail of the Test::Most CPAN module doesn't exactly do what I would expect (and want) it to do. Please have a look at this short example test:
#!/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");
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:
-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.
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.

In reply to die_on_fail of Test::Most only dies after the next test by elTriberium

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.