01: /**
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */package com.tc.test;
04:
05: import org.apache.tools.ant.BuildException;
06: import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter;
07: import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
08:
09: import java.io.OutputStream;
10: import java.util.ArrayList;
11: import java.util.Iterator;
12: import java.util.List;
13:
14: import junit.framework.AssertionFailedError;
15: import junit.framework.Test;
16:
17: /**
18: * @author andrew A
19: */
20: public class TCJUnitFormatter implements JUnitResultFormatter {
21:
22: private final List currentExceptions;
23:
24: public TCJUnitFormatter() {
25: this .currentExceptions = new ArrayList();
26: }
27:
28: public void endTestSuite(JUnitTest theTest) throws BuildException {
29: boolean passed = (theTest.errorCount() == 0 && theTest
30: .failureCount() == 0);
31:
32: if (!passed) {
33: System.out.println("*** " + theTest.getName() + " has "
34: + this .currentExceptions.size() + " exceptions:");
35: Iterator iter = this .currentExceptions.iterator();
36: while (iter.hasNext()) {
37: System.out.println(iter.next().toString());
38: System.out.println();
39: }
40: }
41:
42: this .currentExceptions.clear();
43: System.out.println(" --- TEST FINISHED: "
44: + (passed ? "PASSED" : "FAILED") + " ---");
45: }
46:
47: public void setOutput(OutputStream theStream) {
48: //
49: }
50:
51: public void setSystemError(String arg0) {
52: //
53: }
54:
55: public void setSystemOutput(String arg0) {
56: //
57: }
58:
59: public void startTestSuite(JUnitTest theTest) throws BuildException {
60: String decor = "****************************************************************************";
61: System.out.println();
62: System.out.println(decor);
63: System.out
64: .println("* STARTING TESTSUITE: " + theTest.getName());
65: System.out.println(decor);
66: }
67:
68: public void addError(Test arg0, Throwable arg1) {
69: this .currentExceptions.add(new TestException(arg0, arg1));
70: }
71:
72: public void addFailure(Test arg0, AssertionFailedError arg1) {
73: this .currentExceptions.add(new TestException(arg0, arg1));
74: }
75:
76: public void endTest(Test arg0) {
77: //
78: }
79:
80: public void startTest(Test arg0) {
81: System.out.println();
82: System.out.println(" -- TESTCASE: " + arg0);
83: System.out.println();
84: }
85: }
|