adapter.run(result);
assertEquals(exception, result.errors().nextElement().thrownException());
}
public void testNotifyResult() {
JUnit4TestAdapter adapter = new JUnit4TestAdapter(ErrorTest.class);
TestResult result = new TestResult();
final StringBuffer log = new StringBuffer();
result.addListener(new TestListener() {
public void startTest(junit.framework.Test test) {
log.append(" start ").append(test);
}
public void endTest(junit.framework.Test test) {
log.append(" end ").append(test);
}
public void addFailure(junit.framework.Test test, AssertionFailedError t) {
log.append(" failure ").append(test);
}
public void addError(junit.framework.Test test, Throwable e) {
log.append(" error " + test);
}
});
adapter.run(result);
String testName = String.format("error(%s)", ErrorTest.class.getName());
assertEquals(String.format(" start %s error %s end %s", testName, testName, testName), log.toString());
}