phpunit - if a test case throws an exception (@expectedException) how to finish that method correctly? -
phpunit - if a test case throws an exception (@expectedException) how to finish that method correctly? -
i have test case:
/** * @expectedexception exception */ public function testdie() { savesomething(); doop(); doop(); // here exception triggers restoresomething(); // line wont executed, still need }
something needs set , restore, cant restore because of exception. how dodge it?
catch expected exception, , fail test if no exception caught.
however, having necessary state restoration within test function bad practice. set save in setup() function , restore in teardown() function instead.
phpunit
Comments
Post a Comment