From Test::Simple to Test::Extreme - Bonus Material 50

Testing Domains

Testing Exception Based Code

  • Test::Exception provides routines to report whether code lives or dies, and whether code throws the correct exceptions

        dies_ok {$foo->method1} 'expecting to die';
        lives_ok {$foo->method2} 'expecting to live';
        throws_ok {$foo->method3} qr/division by zero/, 'zero caught okay';
        throws_ok {$foo->method4} 'Error::Simple', 'simple error thrown';
    

 

YAPC::CA << Previous | Index | Next >>
Copyright © 2003 Michael Graham