Testing for multiple exceptions with JUnit 4 annotations

Viewed 55782

Is it possible to test for multiple exceptions in a single JUnit unit test? I know for a single exception one can use, for example

    @Test(expected=IllegalStateException.class)

Now, if I want to test for another exception (say, NullPointerException), can this be done in the same annotation, a different annotation or do I need to write another unit test completely?

7 Answers
Related