getting the path to phpunit from a preference page. added icons to progressComposite
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / testpool / TestPool.java
1 /*
2  * Created on Jul 31, 2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */
7 package net.sourceforge.phpeclipse.phpunit.testpool;
8
9 import java.util.HashMap;
10
11
12 /**
13  * @author Ali Echihabi
14  *
15  * To change the template for this generated type comment go to
16  * Window>Preferences>Java>Code Generation>Code and Comments
17  */
18 public class TestPool {
19
20         //private TestSuite currentParentTestSuite;
21         private HashMap tests;
22         private TestSuite root;
23         private TestSuite currentTestSuite;
24         
25         
26         /**
27          * 
28          */
29         public TestPool(String rootTitle) {
30                 
31                 tests = new HashMap();
32                 root = null;            
33                 currentTestSuite = root;
34                 
35         }
36
37         /**
38          * @param test
39          */
40         public void addTest(TestCase test) {
41                 
42                 tests.put(test.getTestID(), test);
43                 
44                 currentTestSuite.addTestCase(test);
45                 
46                 
47                 //if we run all tests. then this is the end of this test suite.
48                 if( currentTestSuite != root && currentTestSuite.isFinished()) {
49                         
50                         currentTestSuite = currentTestSuite.getParent();
51
52                 }                               
53                 
54         } 
55
56         /**
57          * @param suite
58          * @param numTestsRunSinceStartOfTestSuite
59          */
60         public void addTestSuite(TestSuite suite) {
61         
62         
63         if(root == null) {
64                 root = suite;
65         } 
66         else {
67         
68                 //add as sibling        
69                         currentTestSuite.addTestSuite(suite);
70                         suite.setParent(currentTestSuite);
71
72         }       
73         
74                 currentTestSuite = suite;       
75         }
76
77         /**
78          * @return
79          */
80         public TestSuite getRoot() {
81                 
82                 return root;
83         }
84         
85         /**
86          * @param r
87          */
88         public void setRoot(TestSuite r) {
89                 this.root = r;
90         }
91
92
93         
94         /**
95          * @param testID
96          * @return
97          */
98         public TestCase getTest(String testID) {
99                                 
100                 return (TestCase) tests.get(testID);
101         }
102
103         public String toString() {
104                 
105                 String string = "";
106                 
107                 TestSuite node = root;
108                 
109                 string = root.toString();
110
111                 return string;                  
112         
113         }
114
115
116         public int getNumTestsOverall() {
117         
118                 int total = root.getNumTestCasesExpected();
119                 System.out.println("total: " + total);
120                 return total;
121                                 
122         }
123         
124         public int getNumTestsRun() {
125                 
126                 return tests.size();
127                 
128                         
129         }
130         
131         public int getNumFailures() {
132                 
133                 int total = 0;
134                 
135 //              Iterator i = tests.keySet().iterator();
136 //              String key = "";
137 //              while (i.hasNext()) {
138 //                      
139 //                      
140 //                      key = (String) i.next();
141 //                      TestCase element = (TestCase) tests.get(key);
142 //                      
143 //                      
144 //                      if(element.isFailure())
145 //                              total++;
146 //                      
147 //              }
148                         
149                 return total;
150         }
151         
152         public int getNumErrors() {
153
154                 int total = 0;
155                 
156 //              Iterator i = tests.keySet().iterator();
157 //              String key = "";
158 //              while (i.hasNext()) {
159 //                      
160 //                      
161 //                      key = (String) i.next();
162 //                      TestCase element = (TestCase) tests.get(key);
163 //                                              
164 //                      if(element.isError())
165 //                              total++;
166 //                      
167 //              }
168                         
169                 return total;
170         
171         }
172         
173         
174
175 }