made message: "Include filename doesn't exist in project" configurable
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / testpool / TestSuite.java
1 /*************************************************************************
2  * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
3  *
4  * Plugin for PHP unit Testing.
5  * www.phpeclipse.de
6  * 
7  *************************************************************************/
8
9
10 package net.sourceforge.phpeclipse.phpunit.testpool;
11
12 import java.util.Vector;
13
14
15 public class TestSuite {
16
17
18
19         private boolean hasFailure;
20         private boolean isAllPass;
21         private boolean hasError;
22         private Vector testCases; // current or actual.
23         private Vector testSuites; // current or actual.
24         private String name;
25         private String id;
26         private int numTestCasesExpected; //expected
27         private int numTestCasesRunSoFar;
28         TestSuite parent;
29
30
31
32         /**
33          * @param name
34          * @param testID
35          * @param testCount
36          */
37         public TestSuite(TestSuite parent, String name, String testID, int testCount) {
38                 
39                 this.parent = parent;
40                 this.id = testID;
41                 this.name = name;
42                 this.numTestCasesExpected = testCount;
43         
44                 testCases = new Vector();
45                 testSuites = new Vector();
46                 
47                 hasError = false;
48                 isAllPass = true;
49                 hasFailure = false;
50         }
51                         
52         public void addTestCase(TestCase test) {
53                 testCases.addElement(test);
54                 test.setParentSuite(this);
55                 numTestCasesRunSoFar++;
56         }
57         
58         public void removeTestCase(TestCase test) {}
59         
60         public boolean contains(TestCase test) {
61                 
62                 return false;
63                 
64         }
65         
66         public String toString() {
67                 
68                 String string = "";
69                 
70                 //print test cases.
71                 TestCase tc = null;
72                 for(int i = 0; i < testCases.size(); i++) {
73                         
74                         tc = (TestCase) testCases.elementAt(i);
75                         string += "  - " + tc.getTestID() + ", " + tc.getTestName() + "\n";
76                         
77                         
78                 }
79                 
80                 for(int i = 0; i < testSuites.size(); i++) 
81                         string += ((TestSuite) testSuites.elementAt(i)).toString();
82                 
83                 //print its own test suites.            
84                 return string;
85         }
86
87         /**
88          * @return
89          */
90         public String getId() {
91                 return id;
92         }
93
94         /**
95          * @return
96          */
97         public String getName() {
98                 return name;
99         }
100
101         /**
102          * @return
103          */
104         public int getNumTestCasesExpected() {
105                 return numTestCasesExpected;
106         }
107
108         /**
109          * @param string
110          */
111         public void setId(String string) {
112                 id = string;
113         }
114
115         /**
116          * @param string
117          */
118         public void setName(String string) {
119                 name = string;
120         }
121
122         /**
123          * @param i
124          */
125         public void setNumTestCasesExpected(int i) {
126                 numTestCasesExpected = i;
127         }
128
129         /**
130          * @param suite
131          */
132         public void addTestSuite(TestSuite suite) {
133                 testSuites.addElement(suite);
134                 
135         }
136
137         /**
138          * @return
139          */
140         public boolean isFinished() {
141                 
142                 return numTestCasesRunSoFar >= numTestCasesExpected;
143                 
144         }
145
146         /**
147          * @return
148          */
149         public TestSuite getParent() {
150                 return parent;
151         }
152
153         /**
154          * @param suite
155          */
156         public void setParent(TestSuite suite) {
157                 parent = suite;
158         }
159
160         /**
161          * @return
162          */
163         public int getNumTestCases() {
164                 
165                 return testCases.size();
166         }
167
168         /**
169          * @return
170          */
171         public Vector getTestCases() {
172                 return testCases;
173         }
174
175         /**
176          * @return
177          */
178         public Vector getTestSuites() {
179                 return testSuites;
180         }
181
182         /**
183          * @param vector
184          */
185         public void setTestCases(Vector vector) {
186                 testCases = vector;
187         }
188
189         /**
190          * @param vector
191          */
192         public void setTestSuites(Vector vector) {
193                 testSuites = vector;
194         }
195
196         /**
197          * @return
198          */
199         public boolean hasError() {
200
201                 return hasError;                
202
203         }
204         
205         public void setHasError() {
206                 
207                 if(hasError)
208                         return;
209                         
210                 hasError = true;
211                 
212                 if(parent != null)
213                         parent.setHasError();
214         }
215
216
217         /**
218          * @return
219          */
220         public boolean hasFailure() {
221
222                 return hasFailure;              
223
224         }
225         
226         public void setHasFailure() {
227                 
228                 if(hasFailure)
229                         return;
230                         
231                 hasFailure = true;
232                 
233                 if(parent != null)
234                         parent.setHasFailure();
235         }
236         
237
238         public boolean isAllPass() {
239                 
240                 return !hasError() && !hasFailure();
241                 
242         }       
243 }