1 package junitour;
2
3 import junit.framework.*;
4
5 import java.util.*;
6
7 /**
8 * Extension to TestResult:<br/>
9 *
10 * It collects all incomplete Test cases:<br/>
11 *
12 * On any failure or error of any test case it decides wether
13 * the failing assertion is a UnitTestIncompleteError.<br/>
14 *
15 *
16 * created: by hostlows, at 01.09.2003 / 13:22:08
17 * <pre>
18 *
19 * $Log$
20 * Revision 1.4 2005/08/21 21:38:07 hostlows
21 * more use of Java5 generics
22 *
23 * Revision 1.3 2005/07/31 03:16:04 hostlows
24 * using Java 5 generics for making code simpler: less casts, simpler for-loops
25 *
26 * Revision 1.2 2004/07/08 01:47:50 hostlows
27 * cleanup, new build, license changed to mozilla license...
28 *
29 * Revision 1.1.1.1 2003/11/12 23:32:13 hostlows
30 * Initial import.
31 *
32 * Revision 1.1 2003/10/30 07:13:54 hostlows
33 * First release, which can run as a TextUI-Testrunner and
34 * produces an enhanced output: additionally prints the count of
35 * incomplete Tests! It handles examination of incomplete Testcase over
36 * different classloaders now!
37 * </pre>
38 * @author $Author: hostlows $, created by <a href="mailto:hostlows@users.sf.net">Robert Hostlowsky</a>
39 * @version $Revision: 64 $, $Date: 2005-08-21 23:38:07 +0200 (So, 21 Aug 2005) $
40 */
41
42 public class TourTestResult extends TestResult {
43
44 protected Vector<TestFailure> fNotImplemented;
45 public static final int STATUS_INCOMPLETE= 3;
46 public TourTestResult() {
47 fNotImplemented = new Vector<TestFailure>();
48 }
49 /**
50 * Adds an error to the list of errors. The passed in exception
51 * caused the error.
52 */
53 public synchronized void addError(Test test, Throwable t) {
54 if( UnitTestIncompleteError.isTestIncompleteError(t) ) {
55 fNotImplemented.add(new TestFailure(test, t));
56 final Vector<TestListener> listeners = (Vector) fListeners.clone();
57 for (TestListener l: listeners) {
58 l.addError(test, t);
59 }
60 }
61 else
62 super.addError(test, t);
63 }
64
65 public synchronized void addFailure(Test test, AssertionFailedError t) {
66 if( UnitTestIncompleteError.isTestIncompleteError(t) ) {
67 fNotImplemented.add(new TestFailure(test, t));
68 final Vector<TestListener> listeners = (Vector) fListeners.clone();
69 for (TestListener l: listeners) {
70 l.addFailure(test, t);
71 }
72 }
73 else
74 super.addFailure(test, t);
75 }
76
77 /**
78 * flag: true, if no incomplete test case occured
79 */
80 public synchronized boolean allCompletlyImplemented() {
81 return notImplementedCount() == 0;
82 }
83
84 /**
85 * Gets the number of detected failures.
86 */
87 public synchronized int notImplementedCount() {
88 return fNotImplemented.size();
89 }
90
91 /**
92 * Returns an Enumeration for the incompletes
93 */
94 public synchronized Enumeration<TestFailure> incompletesEnum() {
95 return fNotImplemented.elements();
96 }
97 }