Test::ExceptionTest::Exception is a Perl module to test exception based code. | |
Download |
Test::Exception Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Adrian Howard
- Publisher web site:
- http://search.cpan.org/~adie/Test-Block-0.11/lib/Test/Block.pm
Test::Exception Tags
Test::Exception Description
Test::Exception is a Perl module to test exception based code. Test::Exception is a Perl module to test exception based code.SYNOPSIS use Test::More tests => 5; use Test::Exception; # or if you don't need Test::More use Test::Exception tests => 5; # then... # Check that something died dies_ok { $foo->method1 } 'expecting to die'; # Check that something did not die lives_ok { $foo->method2 } 'expecting to live'; # Check that the stringified exception matches given regex throws_ok { $foo->method3 } qr/division by zero/, 'zero caught okay'; # Check an exception of the given class (or subclass) is thrown throws_ok { $foo->method4 } 'Error::Simple', 'simple error thrown'; # all Test::Exceptions subroutines are guaranteed to preserve the state # of $@ so you can do things like this after throws_ok and dies_ok like $@, 'what the stringified exception should look like'; # Check that a test runs without an exception lives_and { is $foo->method, 42 } 'method is 42'; # or if you don't like prototyped functions dies_ok( sub { $foo->method1 }, 'expecting to die' ); lives_ok( sub { $foo->method2 }, 'expecting to live' ); throws_ok( sub { $foo->method3 }, qr/division by zero/, 'zero caught okay' ); throws_ok( sub { $foo->method4 }, 'Error::Simple', 'simple error thrown' ); lives_and( sub { is $foo->method, 42 }, 'method is 42' ); Requirements: · Perl
Test::Exception Related Software