for (RunListener listener : listeners)
core.addListener( listener );
Request request = RequestCompatibility.createRequest( classes );
SystemOutputCapture capture = new SystemOutputCapture();
capture.start();
Result result;
try {
result = core.run( request );
} finally {
capture.stop();
}
for (RunListener listener : listeners) {
if (listener instanceof JUnit4Formatter) {
try {
JUnit4Formatter formatter = (JUnit4Formatter) listener;
formatter.setSystemOutput( capture.getCapturedOut() );
formatter.setSystemError( capture.getCapturedErr() );
formatter.save();
} catch (IOException ignored) {
ignored.printStackTrace();
}
}