I'm using Test::More module. If i have a .t file with a bunch of tests (mainly using ok()); how can I make the testcase stop after the first failure. What i'm seeing right now is if the first ok fails; the subsequent ok() cases are still being run.
I looked at using Test::More::Bail_OUT; but that will stop all testing to stop (meaning other .t files I have) rather than just testing to stop for the particular file.
Thanks!
The Test::More POD mentions Test::Most for better control. Perhaps die_on_fail does what you need.
Call done_testing() and exit.
ok( first_test(), 'first test' ) or done_testing, exit;
ok( second_test(), 'second test' );
...
In other cases, you can use the skip function inside a block with a SKIP label.
SKIP: {
ok( first_test ) or skip "useless to run the next 4 tests", 4;
ok( second_test );
ok( third_test );
ok( fourth_test );
ok( fifth_test );
}
ok( sixth_test );
done_testing();
The main advantage of skip/SKIP is that it is supported in older versions of Test::More.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With