我想知道这个测试用例应该合格还是不合格 因为 expected = IndexOutOfBoundsException.class 实际上它抛出了Arithmatic异常。谁能解释一下?Junit异常处理
@Test(expected = IndexOutOfBoundsException.class)
public void testDivideNumbers()throws ArithmeticException{
try{
double a = 10/0;
fail("Failed: Should get an Arithmatic Exception");
}
catch (ArithmeticException e) {
}
}
预期= IndexOutOfBoundsException异常,我举办以及醒目的ArithmeticException所以有什么用@Test注解吗? – user707299 2011-04-29 07:44:46