文章列表
junit4 测试异常
- 博客分类:
- junit
在@Test标签后加要测的异常参数就行了。如 @Test(expected= IndexOutOfBoundsException.class)
@Test(expected= IndexOutOfBoundsException.class)
public void testSomething(){
ArrayList list = new ArrayList();
list.get(0);
}