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();
35 currentTestSuite = root;
42 public void addTest(TestCase test) {
44 tests.put(test.getTestID(), test);
46 currentTestSuite.addTestCase(test);
49 //if we run all tests. then this is the end of this test suite.
50 if( currentTestSuite != root && currentTestSuite.isFinished()) {
52 currentTestSuite = currentTestSuite.getParent();
60 * @param numTestsRunSinceStartOfTestSuite
62 public void addTestSuite(TestSuite suite) {
71 currentTestSuite.addTestSuite(suite);
72 suite.setParent(currentTestSuite);
76 currentTestSuite = suite;
82 public TestSuite getRoot() {
90 public void setRoot(TestSuite r) {
100 public TestCase getTest(String testID) {
102 return (TestCase) tests.get(testID);
105 public String toString() {
109 TestSuite node = root;
111 string = root.toString();
117 // This recursion is done at the php side (report generation)
119 // private int countSuiteExpectedTests(TestSuite suite) {
123 // total += suite.getNumTestCasesExpected();
125 // for(int i = 0; i < suite.getTestSuites().size(); i++)
126 // total += countSuiteExpectedTests((TestSuite) suite.getTestSuites().elementAt(i));
128 // System.out.println("total: " + total);
134 public int getNumTestsOverall() {
136 int total = root.getNumTestCasesExpected();
137 System.out.println("total: " + total);
142 public int getNumTestsRun() {
149 public int getNumFailures() {
153 Iterator i = tests.keySet().iterator();
155 while (i.hasNext()) {
158 key = (String) i.next();
159 TestCase element = (TestCase) tests.get(key);
162 if(element.isFailure())
170 public int getNumErrors() {
174 // Iterator i = tests.keySet().iterator();
176 // while (i.hasNext()) {
179 // key = (String) i.next();
180 // TestCase element = (TestCase) tests.get(key);
182 // if(element.isError())