InjectedAfterStatements method evaluate() MultipleFailureException ?

29 views
Skip to first unread message

Eduardo Baungarten

unread,
Aug 29, 2013, 1:21:30 PM8/29/13
to juk...@googlegroups.com
I'm having trouble testing exceptions.

I have the following code snippet:

 myClassTest{

@Rule
public ExpectedException expectedException = ExpectedException.none();
@Test
public void myTeste() {
expectedException.expect(MyException.class);

expectedException.expectMessage("my message error");

throw new MyException("my message error");
}
@After
public void after() {
// my after method
}

}

if I remove the method after my test runs.

I found that the problem is in the class InjectedAfterStatements she captures eceptions and always sends me an exception MultipleFailureException.

please help-me




Eduardo Baungarten

unread,
Aug 29, 2013, 2:09:24 PM8/29/13
to juk...@googlegroups.com
We made a change in class InjectedAfterStatements the evaluate() method.

before:

@Override
  public void evaluate() throws Throwable {
    List<Throwable> errors = new ArrayList<Throwable>();
    errors.clear();
    try {
      prev.evaluate();
    } catch (Throwable e) {
      errors.add(e);
    } finally {
      for (Statement after : afters) {
        try {
          after.evaluate();
        } catch (Throwable e) {
          errors.add(e);
        }
      }
    }
    if (!errors.isEmpty()) {
      throw new MultipleFailureException(errors);
    }
  }


after:
@Override
public void evaluate() throws Throwable {
try {
prev.evaluate();
} catch (Throwable e) {
throw e;
} finally {
for (Statement after : afters) {
try {
after.evaluate();
} catch (Throwable e) {
throw e;
}
}
}
}

have any problem doing this way?
Reply all
Reply to author
Forward
0 new messages