In Java with JUnit 3
public void testIndexOutOfBounds() {
try {
new ArrayList().get(0);
fail("Should have thrown exception");
} catch (IndexOutOfBoundsException e) {
assertEquals("Index: 0, Size: 0", e.getMessage());
}
}
In Java with JUnit 3
public void testIndexOutOfBounds() {
try {
new ArrayList().get(0);
fail("Should have thrown exception");
} catch (IndexOutOfBoundsException e) {
assertEquals("Index: 0, Size: 0", e.getMessage());
}
}
Tags
Java, Junit, Snippets, TDD
Information about Data protection