0

How can I use Junit4 to test the thrown exception while using the exception mapper ?

binodsh
  • 3
  • 3
  • any updates here? also which exception is expected to be thrown by your test should be stated to make question more informative – Naman Nov 26 '16 at 14:11

1 Answers1

0

To test a thrown exception, expected from the execution. Please use :

@Test(expected=<ExpectedException>.class)
public void testThrownException() {
// Your test code that throws the expected exception
}

The test would pass if your code throws the expected exception and fail for assertion failures and any other exception thrown by the code.

Naman
  • 27,789
  • 26
  • 218
  • 353