9d565daffa5da54005c67e549a712ccd2887e406
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / testpool / TestSuite.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.Vector;
10
11 /**
12  * @author Ali Echihabi
13  *
14  * To change the template for this generated type comment go to
15  * Window>Preferences>Java>Code Generation>Code and Comments
16  */
17 public class TestSuite {
18
19
20
21         private Vector testCases; // current or actual.
22         private Vector testSuites; // current or actual.
23         private String name;
24         private String id;
25         private int numTestCasesExpected; //expected
26         private int numTestCasesRunSoFar;
27         TestSuite parent;
28
29         /**
30          * @param name
31          * @param testID
32          * @param testCount
33          */
34         public TestSuite(String name, String testID, int testCount) {
35                 
36                 this.parent = null;
37                 this.id = testID;
38                 this.name = name;
39                 this.numTestCasesExpected = testCount;
40                 
41                 testCases = new Vector();
42                 testSuites = new Vector();
43                 
44         }
45
46         /**
47          * @param name
48          * @param testID
49          * @param testCount
50          */
51         public TestSuite(TestSuite parent, String name, String testID, int testCount) {
52                 
53                 this.parent = parent;
54                 this.id = testID;
55                 this.name = name;
56                 this.numTestCasesExpected = testCount;
57         
58                 testCases = new Vector();
59                 testSuites = new Vector();
60         }
61                         
62         public void addTestCase(TestCase test) {
63                 testCases.addElement(test);
64                 test.setParentSuite(this);
65                 numTestCasesRunSoFar++;
66         }
67         
68         public void removeTestCase(TestCase test) {}
69         
70         public boolean contains(TestCase test) {
71                 
72                 return false;
73                 
74         }
75         
76         public String toString() {
77                 
78                 String string = "";
79                 
80                 //print test cases.
81                 TestCase tc = null;
82                 for(int i = 0; i < testCases.size(); i++) {
83                         
84                         tc = (TestCase) testCases.elementAt(i);
85                         string += "  - " + tc.getTestID() + ", " + tc.getTestName() + "\n";
86                         
87                         
88                 }
89                 
90                 for(int i = 0; i < testSuites.size(); i++) 
91                         string += ((TestSuite) testSuites.elementAt(i)).toString();
92                 
93                 //print its own test suites.            
94                 return string;
95         }
96
97         /**
98          * @return
99          */
100         public String getId() {
101                 return id;
102         }
103
104         /**
105          * @return
106          */
107         public String getName() {
108                 return name;
109         }
110
111         /**
112          * @return
113          */
114         public int getNumTestCasesExpected() {
115                 return numTestCasesExpected;
116         }
117
118         /**
119          * @param string
120          */
121         public void setId(String string) {
122                 id = string;
123         }
124
125         /**
126          * @param string
127          */
128         public void setName(String string) {
129                 name = string;
130         }
131
132         /**
133          * @param i
134          */
135         public void setNumTestCasesExpected(int i) {
136                 numTestCasesExpected = i;
137         }
138
139         /**
140          * @param suite
141          */
142         public void addTestSuite(TestSuite suite) {
143                 testSuites.addElement(suite);
144                 
145         }
146
147         /**
148          * @return
149          */
150         public boolean isFinished() {
151                 
152                 return numTestCasesRunSoFar >= numTestCasesExpected;
153                 
154         }
155
156         /**
157          * @return
158          */
159         public TestSuite getParent() {
160                 return parent;
161         }
162
163         /**
164          * @param suite
165          */
166         public void setParent(TestSuite suite) {
167                 parent = suite;
168         }
169
170         /**
171          * @return
172          */
173         public int getNumTestCases() {
174                 
175                 return testCases.size();
176         }
177
178         /**
179          * @return
180          */
181         public Vector getTestCases() {
182                 return testCases;
183         }
184
185         /**
186          * @return
187          */
188         public Vector getTestSuites() {
189                 return testSuites;
190         }
191
192         /**
193          * @param vector
194          */
195         public void setTestCases(Vector vector) {
196                 testCases = vector;
197         }
198
199         /**
200          * @param vector
201          */
202         public void setTestSuites(Vector vector) {
203                 testSuites = vector;
204         }
205
206 }