Skip to content

Instantly share code, notes, and snippets.

@dagolden
Created June 22, 2015 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagolden/e983bf8f1d72a48fe94d to your computer and use it in GitHub Desktop.
Save dagolden/e983bf8f1d72a48fe94d to your computer and use it in GitHub Desktop.
use 5.008001;
use strict;
use warnings;
package Subtest;
# XXX must be used with no_plan or done_testing
use Test::More 0.88;
use base 'Exporter';
our @EXPORT;
unless ( Test::More->can("subtest") ) {
*subtest = sub {
my ( $label, $code ) = @_;
note "BEGIN SUBTEST $label";
local $Test::Builder::Level = $Test::Builder::Level + 2;
eval { $code->() };
if ( my $err = $@ ) {
fail($label);
diag($err);
}
else {
pass($label);
}
};
push @EXPORT, 'subtest';
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment