【发布时间】:2012-10-26 11:55:25
【问题描述】:
我想为IndexOutOfBoundsException 写一个测试。请记住,我们应该使用 JUnit 3。
我的代码:
public boolean ajouter(int indice, T element) {
if (indice < 0 || indice > (maListe.size() - 1)) {
throw new IndexOutOfBoundsException();
} else if (element != null && !maListe.contains(element)) {
maListe.set(indice, element);
return true;
}
}
经过一些研究,我发现您可以使用 @Test(expected = IndexOutOfBoundsException.class) 在 JUnit 4 中执行此操作,但我在哪里找不到在 JUnit 3 中执行此操作的方法。
如何使用 JUnit 3 进行测试?
【问题讨论】:
标签: java exception junit error-handling junit3