I have a test case as
@Test(expected = IllegalArgumentException.class)
public void test() throws Exception{
..test content...
}
Because I'm using Java Reflection in my test case so the IllegalArgumentException is enwrapped in InvocationTargetException, how can I catch expected IllegalArgumentException instead of InvocationTargetException.
Error message shows as
java.lang.Exception: Unexpected exception, expected<java.lang.IllegalArgumentException> but was<java.lang.reflect.InvocationTargetException>
at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:28)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)