}
}
public void testError() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(
new PrintStream(output)));
String expected = expected(new String[]{".E", "Time: 0",
"Errors here", "", "FAILURES!!!",
"Tests run: 1, Failures: 0, Errors: 1", ""});
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
@Override
public void printErrors(TestResult result) {
getWriter().println("Errors here");
}
};
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() {
@Override
public void runTest() throws Exception {
throw new Exception();
}
});
runner.doRun(suite);
assertEquals(expected, output.toString());
}