![](/img/trans.png)
[英]Testing Exception in junit tests fails even after the exception is thrown
[英]Junit: testing thrown exception while using exception mapper
在使用異常映射器時,如何使用Junit4測試拋出的異常?
測試執行中期望的拋出異常。 請用 :
@Test(expected=<ExpectedException>.class)
public void testThrownException() {
// Your test code that throws the expected exception
}
如果您的代碼引發了預期的異常,並因斷言失敗和代碼引發的任何其他異常而失敗,則測試將通過。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.