Skip to content

Instantly share code, notes, and snippets.

@dagolden

dagolden/Subtest.pm

Created Jun 22, 2015
Embed
What would you like to do?
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