#... use Test::More tests => 42; eval 'use Test::Warn;'; # just ignore if we can't load Test::Warn #... SKIP: { unless ($INC{'Test/Warn.pm'}) { # test if Test::Warn was loaded skip 'Test::Warn is not available', 1; } warning_like { warn "foo" } qr/foo/; # you may need to put this line in a string eval because warning_like is exported by Test::Warn } # ... #### # ... use Test::More; BEGIN { if (eval 'use Test::Warn; 1') { Test::More->import(tests => 42); } else { Test::More->import(skip_all => 'Test::Warn is not available'); # this line won't be reached, see Test::More } } warning_like { warn "foo" } qr/foo/; # ...