KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a test that expects a particular exception, for example: @Test(expected=MyException.class) public void testMyMethod(){ myMethod(); } The myMethod() method actually throws a subclass of MyException , lets call it MySubclassException . Is there anyway to define my test using the @Test annotation to accept subclasses of MyException as well as the class itself? I know that I could simply write the test checking logic myself without using expected by catching the exception and setting a flag, but I was wondering whether or not JUnit already supported matching exception subclasses.
Tags (comma-separated)
Save Edits
Cancel