# App.pm package App; use Foo; sub new { my $class = shift; bless { ua => Foo->new }, $class; } sub check { my $self = shift; my $res = $self->{ua}->get('https://perlmonks.org'); if ($res->code != 200) { return "Monks are offline"; } return "Everything works just fine"; } 1; #### # Foo.pm package Foo; use parent 'LWP::UserAgent'; 1; #### # test_v1.pm package Foo; use HTTP::Response; sub get { return HTTP::Response->new(500); } # Add more packages ad libidum 1; #### # errorcode.t use test_v1; # %INC modification, as prescribed by LanX #BEGIN { # $INC{'Foo.pm'} = __FILE__; #} use Test::More; use App; my $app = App->new; is($app->check,"Monks are offline"); done_testing;