Got a question regarding the usage of junit's ExpectedException rule:
As suggested here: junit ExpectedException Rule starting from junit 4.7 one can test exceptions like this (which is much better then the @Test(expected=Exception.class)):
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
public void testFailuresOfClass() {
 Foo foo = new Foo();
 exception.expect(Exception.class);
 foo.doStuff();
}
Now I needed to test several exceptions in one test method and got a green bar after running the following test and thus thought every test passed.
@Test
public void testFailuresOfClass() {
 Foo foo = new Foo();
 exception.expect(IndexOutOfBoundsException.class);
 foo.doStuff();
 //this is not tested anymore and if the first passes everything looks fine
 exception.expect(NullPointerException.class);
 foo.doStuff(null);
 exception.expect(MyOwnException.class);
 foo.doStuff(null,"");
 exception.expect(DomainException.class);
 foo.doOtherStuff();
}
However after a while I realized that the testmethod is quit after the first check passes. This is ambiguous to say the least. In junit 3 this was easily possible... So here is my question:
How can I test several exceptions within one test using an ExpectedException Rule?