Suppose you're running some unit tests and you want to see if the method ( or script or function or whatever) you're testing fails as it should. How do you setup such a test? I'm hoping for something like this:
ok( $obj->method($my, $bad, $params) == DEATH, 'method dies as expected');
although I don't see how it would work since method
die
s when passed bad parameters and the test script stops.
Is there another way?
Have you tried Test::Exception? dies_ok
should do what you want. Eg:
# Check that something died - we do not care why
dies_ok { $foo->method } 'expecting to die';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With