use strict; use warnings; use Test::More; #-- builder() does not exist in Test::More, just intercept call hierarchy... sub Test::More::builder { my $limit = $Test::More::BAILOUT_LIMIT; my $tb = Test::Builder::Module::builder(@_); my @tests = $tb->summary; my $passed = grep { $_ } @tests; my $failed = @tests - $passed; if ($failed >= $limit) { $tb->BAIL_OUT("Limit of $limit errors reached (passed=$passed, failed=$failed)!"); } return $tb; } #-- here, we set the limit $Test::More::BAILOUT_LIMIT = 2; # or i.e. ... = $ENV{BAILOUT_LIMIT} ok( 1, "okay"); is( 1, 2, "oops"); ok( 0, "test $_/3 will fail..." ) for (1..3); done_testing;