例外をテストするならTest::Fatalが書きやすい 1 2 3 4 5 6 7 8 use strict; use Test::More 0.98; like 'a', qr/a/, q{ like }; eval {die 'a'}; like $@, qr/a/, q{ like eval }; done_testing; 1 2 3 4 5 6 7 8 use strict; use Test::More 0.98; use Test::Exception; like 'a' , qr/a/, q{ like }; throws_ok {die 'a'} qr/a/, q{ throws_ok }; done_testing; 1 2 3 4 5 6 7 8 use strict; use Test::More 0.98; use Test::Fatal; like 'a' , qr/a/, q{ like }; like exception {die 'a'}, qr/a/, q{ like exception }; done_testing; 1 is exception {'a'}, undef, q{ live };