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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -