I have two tests to check the expected exception throw. I am using Junit 4 and has following syntax.
@Test(expected=IllegalArgumentException.class)
public void testSomething(){
..........
}
One of the tests fail even though IllegalArgumentException is thrown and the other passes. Any idea whats missing?? I modified the test which is failing to following and it passes.
public void testSomething(){
try{
............ //line that throws exception
fail();
}catch(IllegalArgumentException e) {
}
}