2 * Created on Jul 31, 2004
4 * To change the template for this generated file go to
5 * Window>Preferences>Java>Code Generation>Code and Comments
7 package net.sourceforge.phpeclipse.phpunit.testpool;
9 import java.util.HashMap;
10 import java.util.Iterator;
11 import java.util.Vector;
15 * @author Ali Echihabi
17 * To change the template for this generated type comment go to
18 * Window>Preferences>Java>Code Generation>Code and Comments
20 public class TestPool {
22 //private TestSuite currentParentTestSuite;
23 private HashMap tests;
24 private TestSuite root;
25 private TestSuite currentTestSuite;
31 public TestPool(String rootTitle) {
33 tests = new HashMap();
34 root = new TestSuite(rootTitle, "-1", 0);
36 currentTestSuite = root;
43 public void addTest(TestCase test) {
45 tests.put(test.getTestID(), test);
47 currentTestSuite.addTestCase(test);
50 //if we run all tests. then this is the end of this test suite.
51 if( currentTestSuite != root && currentTestSuite.isFinished()) {
53 currentTestSuite = currentTestSuite.getParent();
61 * @param numTestsRunSinceStartOfTestSuite
63 public void addTestSuite(TestSuite suite) {
66 currentTestSuite.addTestSuite(suite);
67 suite.setParent(currentTestSuite);
69 currentTestSuite = suite;
75 public TestSuite getRoot() {
83 public void setRoot(TestSuite r) {
93 public TestCase getTest(String testID) {
95 return (TestCase) tests.get(testID);
98 public String toString() {
102 TestSuite node = root;
104 string = root.toString();
110 private int countSuiteExpectedTests(TestSuite suite) {
114 total += suite.getNumTestCasesExpected();
116 for(int i = 0; i < suite.getTestSuites().size(); i++)
117 total += countSuiteExpectedTests((TestSuite) suite.getTestSuites().elementAt(i));
123 public int getNumTestsOverall() {
125 return countSuiteExpectedTests(root);
129 public int getNumTestsRun() {
136 public int getNumFailures() {
140 Iterator i = tests.keySet().iterator();
142 while (i.hasNext()) {
145 key = (String) i.next();
146 TestCase element = (TestCase) tests.get(key);
149 if(element.isFailure())
157 public int getNumErrors() {
161 // Iterator i = tests.keySet().iterator();
163 // while (i.hasNext()) {
166 // key = (String) i.next();
167 // TestCase element = (TestCase) tests.get(key);
169 // if(element.isError())