1 /*************************************************************************
2 * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
4 * Plugin for PHP unit Testing.
7 *************************************************************************/
9 package net.sourceforge.phpeclipse.phpunit.testpool;
11 import java.util.HashMap;
13 public class TestPool {
15 // private TestSuite currentParentTestSuite;
16 private HashMap tests;
18 private TestSuite root;
20 private TestSuite currentTestSuite;
25 public TestPool(String rootTitle) {
27 tests = new HashMap();
29 currentTestSuite = root;
36 public void addTest(TestCase test) {
38 tests.put(test.getTestID(), test);
40 currentTestSuite.addTestCase(test);
42 // if we run all tests. then this is the end of this test suite.
43 if (currentTestSuite != root && currentTestSuite.isFinished()) {
45 currentTestSuite = currentTestSuite.getParent();
53 * @param numTestsRunSinceStartOfTestSuite
55 public void addTestSuite(TestSuite suite) {
62 currentTestSuite.addTestSuite(suite);
63 suite.setParent(currentTestSuite);
67 currentTestSuite = suite;
73 public TestSuite getRoot() {
81 public void setRoot(TestSuite r) {
89 public TestCase getTest(String testID) {
91 return (TestCase) tests.get(testID);
94 public String toString() {
98 TestSuite node = root;
100 string = root.toString();
106 public int getNumTestsOverall() {
108 int total = root.getNumTestCasesExpected();
109 System.out.println("total: " + total);
114 public int getNumTestsRun() {
120 public int getNumFailures() {
124 // Iterator i = tests.keySet().iterator();
126 // while (i.hasNext()) {
129 // key = (String) i.next();
130 // TestCase element = (TestCase) tests.get(key);
133 // if(element.isFailure())
141 public int getNumErrors() {
145 // Iterator i = tests.keySet().iterator();
147 // while (i.hasNext()) {
150 // key = (String) i.next();
151 // TestCase element = (TestCase) tests.get(key);
153 // if(element.isError())