我的測試:這是它強調薩克斯之後的東西。並堅持認爲我有一個try-catch塊....但互聯網說,來測試異常的正確方法是@Test(expected=IllegalArgumentException.class)
Java:Junit4:異常測試不起作用,堅持嘗試catch塊:
@Test(expected= XMLClientNotFoind.class)
public void testGetClientFromIP() throws XMLClientNotFound{
...
assertEquals(c, sax.getClientFromIP("101.0.2.01"));
}
與方法,getClientFromIP是在這裏:
public Client getClientFromIP(String ip) throws XMLClientNotFound {
...
throw new XMLClientNotFound();
}
而我的例外:
public class XMLClientNotFound extends Exception{
}