1 /*************************************************************************
2 * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
4 * Plugin for PHP unit Testing.
7 *************************************************************************/
10 package net.sourceforge.phpeclipse.phpunit.testpool;
12 import java.util.HashMap;
15 public class TestPool {
17 //private TestSuite currentParentTestSuite;
18 private HashMap tests;
19 private TestSuite root;
20 private TestSuite currentTestSuite;
26 public TestPool(String rootTitle) {
28 tests = new HashMap();
30 currentTestSuite = root;
37 public void addTest(TestCase test) {
39 tests.put(test.getTestID(), test);
41 currentTestSuite.addTestCase(test);
44 //if we run all tests. then this is the end of this test suite.
45 if( currentTestSuite != root && currentTestSuite.isFinished()) {
47 currentTestSuite = currentTestSuite.getParent();
55 * @param numTestsRunSinceStartOfTestSuite
57 public void addTestSuite(TestSuite suite) {
66 currentTestSuite.addTestSuite(suite);
67 suite.setParent(currentTestSuite);
71 currentTestSuite = suite;
77 public TestSuite getRoot() {
85 public void setRoot(TestSuite r) {
95 public TestCase getTest(String testID) {
97 return (TestCase) tests.get(testID);
100 public String toString() {
104 TestSuite node = root;
106 string = root.toString();
113 public int getNumTestsOverall() {
115 int total = root.getNumTestCasesExpected();
116 System.out.println("total: " + total);
121 public int getNumTestsRun() {
128 public int getNumFailures() {
132 // Iterator i = tests.keySet().iterator();
134 // while (i.hasNext()) {
137 // key = (String) i.next();
138 // TestCase element = (TestCase) tests.get(key);
141 // if(element.isFailure())
149 public int getNumErrors() {
153 // Iterator i = tests.keySet().iterator();
155 // while (i.hasNext()) {
158 // key = (String) i.next();
159 // TestCase element = (TestCase) tests.get(key);
161 // if(element.isError())