NAME
Test::Builder2::CanLoad - load modules without effecting global variables
SYNOPSIS
package My::Thing;
use Test::Builder2::Mouse;
with "Test::Builder2::CanLoad";
My::Thing->load("Some::Module");
DESCRIPTION
Test::Builder2 must be careful to leave the global state of the test alone. This especially includes things like $@ and $!. Unfortunately, a lot of things change them. require is one of them.
This module provides load as a safe replacement for require which does not affect global variables (except the obvious ones like %INC).
load
$class->load($module);
This works like require to load a module, except it will not affect $! and $@ and not trip a $SIG{__DIE__} handler. Use it internally in your test module when you want to load a module.
It will die on failure if the $module fails to load in which case it will set $@. If you want to trap the failure, see Test::Builder2::CanTry.