Use @Test annotation to test for exceptions being thrown
Lots of tests currently use this idiom:
@Test
public void testFoo() {
try {
foo();
Assert.fail();
} catch (FooException expected) {
// Expected
}
}
They should instead use JUnit's support for catching exceptions:
@Test(expected = FooException.class)
public void testFoo() throws FooException {
foo();
}