How to assert that a certain exception is thrown in JUnit 4 tests?

Posted by Editorial Staff | Updated on

If you want to assert that a certain exception is thrown in JUnit 4 tests? Be careful using expected exception, because it only asserts that the method threw that exception, not a particular line of code in the test.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers