in reply to Test::More usage to test functions that die
If you don't want to use Test::Exception (which I highly recommend), then the easist Test::More way of doing this would be this:
I would also recomment when you test the function with parameters, to also wrap it inside an eval, like this:eval { $a->f1( ) }; ok($@, '... an exception has been thrown'); like($@, qr/\- parameter1 required/, '... and it is the correct except +ion');
This is the idea behind the lives_ok function in Test::Exception.eval { $a->f1("paramter" ) }; ok(!$@, '... no exception has been thrown');
|
|---|