Methods Summary |
---|
public void | addError(junit.framework.Test test, java.lang.Throwable t)Interface TestListener.
An error occurred while running the test.
formatError("\tCaused an ERROR", test, t);
|
public void | addFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)Interface TestListener for JUnit > 3.4.
A Test failed.
addFailure(test, (Throwable) t);
|
public void | addFailure(junit.framework.Test test, java.lang.Throwable t)Interface TestListener for JUnit <= 3.4.
A Test failed.
formatError("\tFAILED", test, t);
|
public void | endTest(junit.framework.Test test)Interface TestListener.
A Test is finished.
if (Boolean.TRUE.equals(failed.get(test))) {
return;
}
synchronized (wri) {
wri.print("Testcase: "
+ JUnitVersionHelper.getTestCaseName(test));
Long l = (Long) testStarts.get(test);
double seconds = 0;
// can be null if an error occurred in setUp
if (l != null) {
seconds =
(System.currentTimeMillis() - l.longValue()) / 1000.0;
}
wri.println(" took " + nf.format(seconds) + " sec");
}
|
public void | endTestSuite(JUnitTest suite)The whole testsuite ended.
StringBuffer sb = new StringBuffer("Tests run: ");
sb.append(suite.runCount());
sb.append(", Failures: ");
sb.append(suite.failureCount());
sb.append(", Errors: ");
sb.append(suite.errorCount());
sb.append(", Time elapsed: ");
sb.append(nf.format(suite.getRunTime() / 1000.0));
sb.append(" sec");
sb.append(StringUtils.LINE_SEP);
// append the err and output streams to the log
if (systemOutput != null && systemOutput.length() > 0) {
sb.append("------------- Standard Output ---------------")
.append(StringUtils.LINE_SEP)
.append(systemOutput)
.append("------------- ---------------- ---------------")
.append(StringUtils.LINE_SEP);
}
if (systemError != null && systemError.length() > 0) {
sb.append("------------- Standard Error -----------------")
.append(StringUtils.LINE_SEP)
.append(systemError)
.append("------------- ---------------- ---------------")
.append(StringUtils.LINE_SEP);
}
sb.append(StringUtils.LINE_SEP);
if (out != null) {
try {
out.write(sb.toString().getBytes());
wri.close();
out.write(inner.toString().getBytes());
out.flush();
} catch (IOException ioex) {
throw new BuildException("Unable to write output", ioex);
} finally {
if (out != System.out && out != System.err) {
FileUtils.close(out);
}
}
}
|
private void | formatError(java.lang.String type, junit.framework.Test test, java.lang.Throwable t)
synchronized (wri) {
if (test != null) {
endTest(test);
failed.put(test, Boolean.TRUE);
}
wri.println(type);
wri.println(t.getMessage());
String strace = JUnitTestRunner.getFilteredTrace(t);
wri.print(strace);
wri.println("");
}
|
public void | setOutput(java.io.OutputStream out){@inheritDoc}.
this.out = out;
|
public void | setSystemError(java.lang.String err){@inheritDoc}.
systemError = err;
|
public void | setSystemOutput(java.lang.String out){@inheritDoc}.
systemOutput = out;
|
public void | startTest(junit.framework.Test t)Interface TestListener.
A new Test is started.
testStarts.put(t, new Long(System.currentTimeMillis()));
failed.put(t, Boolean.FALSE);
|
public void | startTestSuite(JUnitTest suite)The whole testsuite started.
if (out == null) {
return; // Quick return - no output do nothing.
}
StringBuffer sb = new StringBuffer("Testsuite: ");
sb.append(suite.getName());
sb.append(StringUtils.LINE_SEP);
try {
out.write(sb.toString().getBytes());
out.flush();
} catch (IOException ex) {
throw new BuildException("Unable to write output", ex);
}
|