my $mock = Test::MockObject->new(); $mock->fake_module('Foo::Bar' => ( 'import' => sub { die "Foo::Bar could not be loaded" } )); use_ok('Foo::Bar');