1
,我有以下的僞代碼PHPUnit的setExpectedException後停止執行()
public function testSomething() {
// assert something
// assert something else
$this->setExpectedException(...);
// trigger my exception here
// do one last thing
}
我看到的問題,正在引發異常後的代碼從來沒有。它是否正確?
這只是一個普遍想知道的地方 - 如果這是正常的,我會重構我的測試直接執行try/catch和fail()
測試如果沒有被捕獲。
更好的方法是將測試後必須執行的代碼放入'tearDown'中,PHPUnit將調用是否拋出異常。 –
好點。我主要考慮你可能想要做出的其他斷言。 – Schleis