From a8baaf8da47ce3c580a814ded602de8949f1631e Mon Sep 17 00:00:00 2001 From: shleh Date: Fri, 17 Sep 2004 19:30:36 +0000 Subject: [PATCH] First commit in a looooooong time. I had connectivity problems. Using a testPool to show progress and test result info. Added icons... --- net.sourceforge.phpeclipse.phpunit/.classpath | 12 + net.sourceforge.phpeclipse.phpunit/.project | 39 +++ .../build.properties | 4 + .../icons/sample.gif | Bin 0 -> 983 bytes net.sourceforge.phpeclipse.phpunit/icons/test.gif | Bin 0 -> 362 bytes .../icons/testerr.gif | Bin 0 -> 374 bytes .../icons/testfail.gif | Bin 0 -> 374 bytes .../icons/testok.gif | Bin 0 -> 380 bytes .../icons/tsuite.gif | Bin 0 -> 358 bytes .../icons/tsuiteerror.gif | Bin 0 -> 376 bytes .../icons/tsuitefail.gif | Bin 0 -> 376 bytes .../icons/tsuiteok.gif | Bin 0 -> 382 bytes net.sourceforge.phpeclipse.phpunit/plugin.xml | 5 +- .../src/Messages.java | 43 ++++ .../phpeclipse/phpunit/PHPUnitPlugin.java | 182 +++++++++++++++ .../phpeclipse/phpunit/PHPUnitView.java | 243 ++++++++++++++++---- .../phpeclipse/phpunit/ProgressInfoComposite.java | 36 +++- .../phpeclipse/phpunit/ReportListener.java | 4 +- .../phpeclipse/phpunit/ResultsInfoComposite.java | 46 +++-- .../phpeclipse/phpunit/SettingsInfoComposite.java | 75 ++++++ .../sourceforge/phpeclipse/phpunit/TestCase.java | 77 ------ .../sourceforge/phpeclipse/phpunit/TestPool.java | 37 --- .../phpunit/TestPoolContentProvider.java | 91 ++++++++ .../phpeclipse/phpunit/TestPoolLabelProvider.java | 89 +++++++ .../sourceforge/phpeclipse/phpunit/TestSuite.java | 35 --- .../phpeclipse/phpunit/actions/RunTestsAction.java | 50 ++++- .../phpeclipse/phpunit/testpool/TestCase.java | 131 +++++++++++ .../phpeclipse/phpunit/testpool/TestPool.java | 180 +++++++++++++++ .../phpeclipse/phpunit/testpool/TestSuite.java | 206 +++++++++++++++++ 29 files changed, 1364 insertions(+), 221 deletions(-) create mode 100644 net.sourceforge.phpeclipse.phpunit/.classpath create mode 100644 net.sourceforge.phpeclipse.phpunit/.project create mode 100644 net.sourceforge.phpeclipse.phpunit/build.properties create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/sample.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/test.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/testerr.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/testfail.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/testok.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/tsuite.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/tsuiteerror.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/tsuitefail.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/icons/tsuiteok.gif create mode 100644 net.sourceforge.phpeclipse.phpunit/src/Messages.java create mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitPlugin.java create mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/SettingsInfoComposite.java delete mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestCase.java delete mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPool.java create mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolContentProvider.java create mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java delete mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestSuite.java create mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestCase.java create mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestPool.java create mode 100644 net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestSuite.java diff --git a/net.sourceforge.phpeclipse.phpunit/.classpath b/net.sourceforge.phpeclipse.phpunit/.classpath new file mode 100644 index 0000000..26a1867 --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/net.sourceforge.phpeclipse.phpunit/.project b/net.sourceforge.phpeclipse.phpunit/.project new file mode 100644 index 0000000..7c1262f --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/.project @@ -0,0 +1,39 @@ + + + net.sourceforge.phpeclipse.phpunit + + + org.eclipse.core.boot + org.eclipse.core.resources + org.eclipse.core.runtime + org.eclipse.ui + org.eclipse.ui.views + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + net.sourceforge.metrics.builder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + net.sourceforge.metrics.nature + + diff --git a/net.sourceforge.phpeclipse.phpunit/build.properties b/net.sourceforge.phpeclipse.phpunit/build.properties new file mode 100644 index 0000000..e07c485 --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/build.properties @@ -0,0 +1,4 @@ +source.phpunit.jar = src/ +bin.includes = plugin.xml,\ + *.jar,\ + phpunit.jar diff --git a/net.sourceforge.phpeclipse.phpunit/icons/sample.gif b/net.sourceforge.phpeclipse.phpunit/icons/sample.gif new file mode 100644 index 0000000000000000000000000000000000000000..34fb3c9d8cb7d489681b7f7aee4bdcd7eaf53610 GIT binary patch literal 983 zcmZ?wbhEHb6krfw_|CxKYUg-n!?izO{@9*?jxd%4aX0yzy`dymabz zw#(eg=y~&N&n)dZv2xzduG}5lraiApo3(c4*{Ylg5#|$JO_EEZ<^|a2`Z*=9ns7DV zy=TR&gYw*7f%auV?ip3tvjRPmcdoho{K?x$_vR?C#t5&<;~V}S*>OMCr>h}%%bLZ9 zmo3`hYEwTICo-TTCZwgTsC&VjZRgJ1eE#fBa^%9R zmmfWS@;bnyJ27HWY}kxYzv(Hl>yu;FCPlAEh+34Muq-8Rb6C)<8qA3{r2e5 z`$vyngh#H=FWlqqvnapfc5%(!sQ4v?r7J61-&eJNEN^;KTK}T7{#i-gJh%G*9vcYdwv_*~xdw!Gz4Va?T!sXyyF@8?w<>X`X=#j%uHV4GRvj@+tE@ zQ%F!a)GKcn^~8abN>4la1UNXVL;{ZWi)lEwyeatDu%Lr6;aASiLrXXW zQm#)X#icV0g`|M<4mw3vi-wMpyhQa3ghZtpgn7_8UsYdR&|a#Ezz>_prCD9;5Mu2U0z z=Vt{j$q!vr5Hu$@U`AH-s*3nE)iF!TB4-w4Y--Nk((XPtrMkqwuGFu(IH0}Cr@7pB zV!cOCt=HUE*Xd1e8~W|m^f)Z-_PIw`u6kBo!8IKKfax?t~P01UFych!tLF9?Y@?iB5nJlT&E`b z&d&;5k{`OLAZSi*z>KWuRTc4Ts$-UvMb0e9*wmc6rQLmQN_C0<{8{xow=SwH^=q&4 zX)gDjSnttO>ovF4b$XNAhJL#>Jr2veoECLB?_N=Mdf%Ka6Kwy30Rsk5{K>+|z+lOs z1CjyxiGgkMfjI`{+EV>T6$KCGSmmFJI4GnUvA%Ui5Syl}!UF@BWpiZJCYJmXusk!x zw4GgKQHVzoyKkm(0Z&6?gT5t0TRVeLmk?KvK`RprBMTFQnzXDEuOzQ-D~koQ1q%bu zvgJH_t&EG989TfAh4{5suU#)8C9ljW&Z#qh;bI2vqsO?lCQO>bpsAsL;bLn?o7c7L JH=G<9tN}1wpSu76 literal 0 HcmV?d00001 diff --git a/net.sourceforge.phpeclipse.phpunit/icons/testfail.gif b/net.sourceforge.phpeclipse.phpunit/icons/testfail.gif new file mode 100644 index 0000000000000000000000000000000000000000..de59bac205fc85a6b18edf05a4ffbe8afe392b04 GIT binary patch literal 374 zcmZ?wbhEHb6krfwxXQrrGmk8dZet4&&0m%6dBaC^62yRYS>NZbA>*QtrV z^Roh%X;>EkuwW2HZ|vNX?LHSQeEOde^&j@t&8eP{o1R1 zn#+AB)_e5Sdd+Qho!;cOq2F#zkHhjVr$rskyH}K*-Zy8<1l#{$z<>c1f3h$#Fjz9^ zfMh^^VqlwmV2(k#wp9O7#lizQR{5tS4hS(utZ$eR#HQ)0@W8-j*&I%_i6v12f@h|f zwz7*X3h^jn_08liU}|V=(6{7nYv&f~5@PK!Xysw!XXD{kla^KDl;qTHWwYS5VB_Xk zwwyz+m46X0e`hzJ5TEwywd*CM(S#;(vT+GdW^ccI=gh^AlH8s>PTx{)V^SXBZ JhLa+$;W_50`V z`u6$!-0SAgqqJDKwhk8tdcTJIhNQ`|-orOi0f<~~9KCFyDr;0+Nh(o)mcFVq;w2(dj|NsC0 z{{R30A^8LW002G!EC2ui01yBW000J=K%daZD;kf*A#uQLI(bSPV8Z}duK=6!woow^ z;PB$6#0fBrbXvd=;FP+=sAS4$Qu0JjxeJ5>fPsKCJ`je75DkhA1&lR?6Oj`S5Gx=e zCkP%0GLVrMJrD<@qz5yF5~)2EiHiyi3NVE|7ZyDd5FH;RC aFNF~fJrTz)EiBg8g@}eq+}++nK>$0S@UV3N literal 0 HcmV?d00001 diff --git a/net.sourceforge.phpeclipse.phpunit/icons/tsuite.gif b/net.sourceforge.phpeclipse.phpunit/icons/tsuite.gif new file mode 100644 index 0000000000000000000000000000000000000000..5198579fd660e0a51796d26e95003dc973bf03b4 GIT binary patch literal 358 zcmZ?wbhEHb6krfwxXQrrhoBba8jgW(us)&HfA&}aOZE}dcouraf#h9Qb*vZN#|mqBCf#6Ki{Y*H99zX z<@R|^l0ZfN&bs-V^>#ZZfah6X@_x>Uv-K9;(0C2l|J=le*1T?oLKMCRqZve&3Ss0 z+wRphXAUi0-Q%#d)9KprMO!A=Zs@Z+y{Y2FhKidf7XAkV1{^@~CkrD3gE@l^NFL-T z2DYgOqH{b{?)7;nCY^LSGRZ^IsW|h}0{8I7s25@hH*R|~?TS%3`lZ+PW{usH$jLu* zG@ZI?&N}6u%42A3VqlMn(`#U2VPs)q;7d(U*Kc4kV>V-95S7dqkrdHtV4T6s$iOAX z#wNT*d-2lcys{D!0^2mEPM^sjs3ar9qr{`x+1<;)$$grin_sn|xlvt3`PwzL#9QW$ G4AuaMsjGPa literal 0 HcmV?d00001 diff --git a/net.sourceforge.phpeclipse.phpunit/icons/tsuitefail.gif b/net.sourceforge.phpeclipse.phpunit/icons/tsuitefail.gif new file mode 100644 index 0000000000000000000000000000000000000000..d247a8fef52b61b9a9274093ce7e17792d68afff GIT binary patch literal 376 zcmZ?wbhEHb6krfwxXQrr`tbG7m+!w_(k8zD0#xw(+s{A0|NOo4`q}x%w*#kT7jExv z+cv{`dbIPLB>%;^v8yXHH#M)kw8OZ`ue!v4@w}GiN}u{Nzx}&cPOSIns`i@K<~+U0 zZTIS$Gl!P0?r~V!>2&S*qAe3_H}u(^-c)g7L&eP#3;%-w0}i10lZBCi!JI({BoFcv z1KZRC(K#L}_xd~@CY+QxGRfnnLviM%1@7VvTrZdsZrs*p+7+X8^h>Yn%^JHYk&}Ps zh&r{_oOQ}QmB-!K#LW~Fr`N#4Cd9_W&6S#-uHV3B#%spLEh?EWA}ONPAT)zlh?`Z8 zkx_V!_Tr_>Ib|gz__t|Hoj#LWKuJc1Ly1GPv%8m@h5a-iJD+MpbECS7^0jMfiMPxh G8LRp03 literal 0 HcmV?d00001 diff --git a/net.sourceforge.phpeclipse.phpunit/icons/tsuiteok.gif b/net.sourceforge.phpeclipse.phpunit/icons/tsuiteok.gif new file mode 100644 index 0000000000000000000000000000000000000000..e3db1eb3c8abb895fad09991e94291b01342febb GIT binary patch literal 382 zcmV-^0fGKUNk%w1VGsZi0M!5h`1$-eVo#%OU8{L%vV*D8xHE!Idvs5uo`i#WOn-Jxzq_fC ze@KdZN}h&8mx4ySt9;DDrK^lUrHMk;$D*{5J+O{G%d&XLuz17!fIA%=I~W!SA`=q}w=IAgJ3AB?77QmLAqOW1E`S#l cI~TwN2GI%z3Mznufh;K~+}tZ+;5 + class="net.sourceforge.phpeclipse.phpunit.PHPUnitPlugin"> @@ -20,7 +20,7 @@ + id="net.sourceforge.phpeclipse.phpunit.PHPUnitView"> testsuite1->testcase->test_function */ - private int numTests; // total number of tests - private int numTestsRun; // number of tests run so far - private int numFailures; // number of failures so far - private int numErrors; // number of errors so far - private int numPasses; // number of passes so far (they should add up) + private static PHPUnitView view = null; private XMLReportHandler handler; - - - + private TestPool testPool; private Button startButton; private ProgressInfoComposite progressInfoComposite; private ResultsInfoComposite resultsInfoComposite; - private Group settingsInfoComposite; //TODO: move somewhere else, launcher, wizard or preferences. + private SettingsInfoComposite settingsInfoComposite; //TODO: move somewhere else, launcher, wizard or preferences. public PHPUnitView() { - handler = new XMLReportHandler(); - testPool = new TestPool(); + if(view == null) + view = this; } + + public static PHPUnitView getDefault() { + + + return view; + } public void createPartControl(Composite parent) { - parent.setLayout(new FillLayout(SWT.VERTICAL)); + //parent.setLayout(new FillLayout(SWT.VERTICAL)); + + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + + // set title and layout + parent.setLayout(gridLayout); + //Launch ToolBar: setActions(); - //Build the progress info Composite s + //Build the progress info Composites progressInfoComposite = new ProgressInfoComposite(parent); + progressInfoComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); - + + //Build the result info composite resultsInfoComposite = new ResultsInfoComposite(parent); + resultsInfoComposite.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.FILL_BOTH)); //build the settings composite - buildSettingsComposite(parent); + //buildSettingsComposite(parent); + + settingsInfoComposite = new SettingsInfoComposite(parent, SWT.NONE); + startButton = new Button(parent, SWT.CENTER); startButton.setText("Start Tests"); @@ -104,12 +129,20 @@ public class PHPUnitView extends ViewPart { public void mouseDown(MouseEvent arg0) { - startTests(); + } public void mouseUp(MouseEvent arg0) { + try { + String testFile = settingsInfoComposite.getTestSuite(); + startTests(testFile); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } }); // end add action listener. @@ -122,8 +155,8 @@ public class PHPUnitView extends ViewPart { private void buildSettingsComposite(Composite parent) { - settingsInfoComposite = new Group(parent, SWT.NONE); -// settingsInfoComposite.setText("Settings"); + //settingsInfoComposite = new Group(parent, SWT.NONE); + //settingsInfoComposite.setText("Settings"); // settingsInfoComposite.setLayout(new GridLayout(2,false)); // // @@ -138,9 +171,7 @@ public class PHPUnitView extends ViewPart { // phpPathLabel.setText("php Path:"); // //testSuiteLabel.setLayoutData(new GridData()) // Text phpPathText = new Text(settingsInfoComposite, SWT.NONE); - - } private void setActions() { @@ -180,41 +211,41 @@ public class PHPUnitView extends ViewPart { * * @param testID */ - public void markTestPassed(String testID) { + private void markTestPassed(String testID) { // testid, use it in hashmap to retrieve tree item of test and // change icon color, increment pass counter, etc... - testPool.getTest(testID).setVerdict(Test.PASS); + testPool.getTest(testID).setVerdict(TestCase.PASS); } - public void markTestStarted(String testID) { + private void markTestStarted(String testID) { } - public void createNewTest(String testName, String testID) { + private void createNewTest(String testName, String testID) { - testPool.addTest(new Test(testName, testID)); + testPool.addTest(new TestCase(testName, testID)); } - public void markTestFail(String testID) { - numFailures++; - testPool.getTest(testID).setVerdict(Test.FAIL); + private void markTestFail(String testID) { + + testPool.getTest(testID).setVerdict(TestCase.FAIL); } - public void markTestingStarted(int numTestsToBeRun) { + private void markTestingStarted(int numTestsToBeRun) { + - this.numTests = numTestsToBeRun; //reportArea.append("Tests started expecting: " + numTests + " \n"); } - public void markTestingFinished() { + private void markTestingFinished() { //reportArea.append("end all tests \n"); @@ -222,25 +253,107 @@ public class PHPUnitView extends ViewPart { } // action to start tests: - private void startTests() { + public void startTests() throws IOException { + +// // preparation: +// // take the full test suite (could containt other test suites). +// // create temp php file that starts that suite and uses socketTestReport +// // as a test result reporter. +// // add listener: localhost , port 13579 +// // start listening at port. +// +// testPool = new TestPool("RUN MONDAY 11:15 PM"); +// listenForReports(); +// +// try { +// Runtime.getRuntime().exec("php.exe \"C:/Program Files/Apache Group/Apache2/htdocs/phpUnit/suite.php\""); +// } catch (Exception e) { +// +// e.printStackTrace(); +// } + + startTests("C:/Program Files/Apache Group/Apache2/htdocs/phpUnit/suite.php"); + + } + + public void startTests(String testSuite) throws IOException { + + //testSuite: the name of the file containing the suite we want to run. + // we will put that test suite inside a contained that uses our SocketResult. + + + //reset from previous run + reset(); + + //where the plugin's temp files should go + String tempFolder = "C:\\tmp"; + String tempFileName = "temTest.php"; + + //create the file. + File testFile = new File(tempFolder + "/" + tempFileName); + BufferedWriter out = new BufferedWriter(new FileWriter(testFile)); + + out.write("addTest(new TestSuite(\"" + testSuiteName + "\"));" + "\n"); + + + + //out.write("$suite->addTest(new TestSuite(\"MoreTesterTests\"));" + "\n"); + + //out.write("$suite->addTest(new TestSuite(\"ManyFailingTests\"));" + "\n"); + //out.write("$suite->addTest(new TestSuite(\"AssertEqualsTests\"));" + "\n"); + + out.write("$result = new SocketTestResult();" + "\n"); + out.write("$suite->run($result);" + "\n"); + out.write("$result->report(); " + "\n"); + out.write("" + "\n"); + out.write("" + "\n"); + + out.write("?>" + "\n"); + + out.flush(); + out.close(); listenForReports(); try { - Runtime.getRuntime().exec("php.exe \"C:/Program Files/Apache Group/Apache2/htdocs/phpUnit/suite.php\""); - } catch (IOException e) { - // TODO Auto-generated catch block + Runtime.getRuntime().exec("php.exe " + tempFolder + "/" + tempFileName); + } catch (Exception e) { + e.printStackTrace(); } + + //testFile.delete(); + + } + /** + * + */ + private void reset() { + + handler = new XMLReportHandler(); + testPool = new TestPool("Ali Baba"); + + progressInfoComposite.resetInfo(); + resultsInfoComposite.resetInfo(); + } /** @@ -281,9 +394,14 @@ public class PHPUnitView extends ViewPart { markTestingStarted(new Integer(testCount).intValue()); - }else if (command.equals("testStarted")) { + } else if (command.equals("testSuiteStarted")) { + + createNewTestSuite("TestSuiteName: " + testID, testID, new Integer(testCount).intValue()); + markTestSuiteStarted(testID); + + } else if (command.equals("testStarted")) { - createNewTest("testName", testID); + createNewTest("TestName: " + testID, testID); markTestStarted(testID); } else if (command.equals("testFINISHED")) { @@ -295,10 +413,42 @@ public class PHPUnitView extends ViewPart { markTestingFinished(); } + + update(); + - progressInfoComposite.updateInfo(numTests, numTestsRun, numFailures, numErrors); + + } + + /** + * + */ + private void update() { + + //progressInfoComposite.updateInfo(numTests, testPool.getNumTestsRun(), numFailures, numErrors); + progressInfoComposite.updateInfo(testPool); resultsInfoComposite.updateInfo(testPool); + + } + + /** + * @param testID + */ + private void markTestSuiteStarted(String testID) { + // TODO Auto-generated method stub + + } + /** + * @param string + * @param testID + * @param testCount + */ + private void createNewTestSuite(String name, String testID, int testCount) { + + TestSuite suite = new TestSuite(name, testID, testCount); + testPool.addTestSuite(suite); + } /** @@ -306,7 +456,6 @@ public class PHPUnitView extends ViewPart { */ private void markTestFinished() { - numTestsRun++; } diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java index 7d779e4..3781fde 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java @@ -6,6 +6,8 @@ */ package net.sourceforge.phpeclipse.phpunit; +import net.sourceforge.phpeclipse.phpunit.testpool.TestPool; + import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; @@ -74,13 +76,21 @@ public class ProgressInfoComposite extends Composite { labelErrorsVal.setText("0"); } + public void resetInfo() { + + labelErrorsVal.setText("0"); + labelFailuresVal.setText("0"); + labelRunsVal.setText("0 / 0"); + progressBar.setSelection(0); + + } + public void updateInfo(int numTests, int numTestsRun, int numFailures, int numErrors) { //update progress bar progressBar.setMaximum(numTests); progressBar.setSelection(numTestsRun); - - System.out.println("numTestsRun: " + numTestsRun); + //update labels labelRunsVal.setText(numTestsRun + " / " + numTests); @@ -93,4 +103,26 @@ public class ProgressInfoComposite extends Composite { } + + public void updateInfo(TestPool testPool) { + + int numTestsOverall = testPool.getNumTestsOverall(); + int numTestsRun = testPool.getNumTestsRun(); + + //update progress bar + progressBar.setMaximum(numTestsOverall); + progressBar.setSelection(numTestsRun); + + + //update labels + labelRunsVal.setText(numTestsRun + " / " + numTestsOverall); + labelFailuresVal.setText("" + testPool.getNumFailures()); + labelErrorsVal.setText("" + testPool.getNumErrors()); + + //TODO: change Failures label to red if some exist. + + + + } + } diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ReportListener.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ReportListener.java index bb4686d..a26ec25 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ReportListener.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ReportListener.java @@ -30,9 +30,9 @@ public class ReportListener extends Thread { while ( (report = in.readLine()) != null && (report != "end_all_tests") ) { - System.out.println("received something..."); + //System.out.println("received something..."); view.handleReport(report); - System.out.println(report); + //System.out.println(report); } //reportArea.append("Finished!"); diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ResultsInfoComposite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ResultsInfoComposite.java index 8f50171..627da42 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ResultsInfoComposite.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ResultsInfoComposite.java @@ -6,10 +6,13 @@ */ package net.sourceforge.phpeclipse.phpunit; +import net.sourceforge.phpeclipse.phpunit.testpool.TestPool; + +import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; /** * @author Ali Echihabi @@ -20,7 +23,8 @@ import org.eclipse.swt.widgets.Text; public class ResultsInfoComposite extends Composite { - private Text reportArea; // TODO: replace with Tree display like JUnit + + private TreeViewer treeViewer; /** * @param arg0 @@ -28,32 +32,38 @@ public class ResultsInfoComposite extends Composite { */ public ResultsInfoComposite(Composite parent) { - super(parent, SWT.NONE); + super(parent, SWT.BORDER); - setLayout(new FillLayout(SWT.VERTICAL)); + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + + setLayout(layout); + + treeViewer = new TreeViewer(this, SWT.BORDER | SWT.SHADOW_ETCHED_IN); - reportArea = - new Text( - this, - SWT.MULTI - | SWT.BORDER - | SWT.WRAP - | SWT.V_SCROLL - | SWT.READ_ONLY); + treeViewer.getControl().setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_BOTH | GridData.GRAB_VERTICAL)); + + TestPoolLabelProvider labelProvider = new TestPoolLabelProvider(); + TestPoolContentProvider contentProvider= new TestPoolContentProvider(); + + treeViewer.setContentProvider(contentProvider); + treeViewer.setLabelProvider(labelProvider); + } + public void resetInfo() { + + treeViewer.setInput(null); + } public void updateInfo(TestPool testPool) { // take care of the TreeView and its content and label providers. + + treeViewer.setInput(testPool.getRoot()); } - - - - - } diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/SettingsInfoComposite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/SettingsInfoComposite.java new file mode 100644 index 0000000..1babb56 --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/SettingsInfoComposite.java @@ -0,0 +1,75 @@ +/* + * Created on Sep 11, 2004 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package net.sourceforge.phpeclipse.phpunit; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; + +/** + * @author Ali Echihabi + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class SettingsInfoComposite extends Composite { + + FileDialog dialog; + Button button; + + String testSuitePath; + + /** + * @param arg0 + * @param arg1 + */ + public SettingsInfoComposite(Composite parent, int style) { + + super(parent, style); + + dialog = new FileDialog(parent.getShell()); + + button = new Button(parent, SWT.NONE); + button.setText("Browser for test..."); + + button.addMouseListener(new MouseListener() { + public void mouseDoubleClick(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + + public void mouseDown(MouseEvent arg0) { + + testSuitePath = dialog.open(); + System.out.println("file: " + testSuitePath); + + } + + public void mouseUp(MouseEvent arg0) { + // TODO Auto-generated method stub + + } + }); + + + + + + } + + + public String getTestSuite() { + + return testSuitePath; + } + + + +} diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestCase.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestCase.java deleted file mode 100644 index beac173..0000000 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestCase.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Created on Jul 31, 2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package net.sourceforge.phpeclipse.phpunit; - -/** - * @author Ali Echihabi - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class TestCase { - - /** - * @param testName - * @param testID - */ - public TestCase(String testName, String testID) { - - this.testName = testName; - this.testID = testID; - } - - static final String PASS = "PASS"; - static final String FAIL = "PASS"; - static final String ERROR = "PASS"; - - String testName; - String testID; - String verdict; - - /** - * @return - */ - public String getTestID() { - return testID; - } - - /** - * @return - */ - public String getTestName() { - return testName; - } - - /** - * @return - */ - public String getVerdict() { - return verdict; - } - - /** - * @param string - */ - public void setTestID(String string) { - testID = string; - } - - /** - * @param string - */ - public void setTestName(String string) { - testName = string; - } - - /** - * @param string - */ - public void setVerdict(String string) { - verdict = string; - } - -} diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPool.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPool.java deleted file mode 100644 index a4ba019..0000000 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPool.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Created on Jul 31, 2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package net.sourceforge.phpeclipse.phpunit; - -import java.util.HashMap; - -/** - * @author Ali Echihabi - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class TestPool { - - private HashMap tests; - - public TestPool() { - - tests = new HashMap(); - } - - public void addTest(TestCase test) { - - tests.put(test.getTestID(), test); - - } - - public TestCase getTest(String testID) { - - return (TestCase) tests.get(testID); - } - -} diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolContentProvider.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolContentProvider.java new file mode 100644 index 0000000..96489da --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolContentProvider.java @@ -0,0 +1,91 @@ +/* + * Created on Aug 8, 2004 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package net.sourceforge.phpeclipse.phpunit; + +import java.util.Vector; + +import net.sourceforge.phpeclipse.phpunit.testpool.*; + +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +/** + * @author Ali Echihabi + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class TestPoolContentProvider implements ITreeContentProvider { + + + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ + public Object[] getChildren(Object parentElement) { + + if(parentElement instanceof TestSuite) { + + Vector allChildren = new Vector(); + allChildren.addAll(((TestSuite)parentElement).getTestCases()); + allChildren.addAll(((TestSuite)parentElement).getTestSuites()); + + return allChildren.toArray(); + + } else { + return new Object[0]; + } + + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ + public Object getParent(Object element) { + + if(element instanceof TestSuite) + return ((TestSuite)element).getParent(); + else if (element instanceof TestCase) + return ((TestCase)element).getParentSuite(); + else + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + public boolean hasChildren(Object element) { + + return getChildren(element).length > 0; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object inputElement) { + + return getChildren(inputElement); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // TODO Auto-generated method stub + + } + +} diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java new file mode 100644 index 0000000..6977a6d --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java @@ -0,0 +1,89 @@ +/* + * Created on Aug 8, 2004 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package net.sourceforge.phpeclipse.phpunit; + +import java.net.MalformedURLException; +import java.net.URL; + +import net.sourceforge.phpeclipse.phpunit.testpool.TestCase; +import net.sourceforge.phpeclipse.phpunit.testpool.TestSuite; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +/** + * @author Ali Echihabi + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class TestPoolLabelProvider extends LabelProvider { + + //TODO: replace with installDir + path + private static String iconsPath = "C:\\Documents and Settings\\Ali Echihabi\\My Documents\\workspace.eclipse2.1\\net.sourceforge.phpeclipse.phpunit\\icons"; + + public String getText(Object element) { + + if(element instanceof TestSuite) + return ((TestSuite)element).getName(); + else if(element instanceof TestCase) + return ((TestCase)element).getTestName(); + else + return "UNKNOWN ELEMENT TYPE"; + + + + } + + public Image getImage(Object element) { + + Image image = null; + + try { + + String icon = ""; + if(element instanceof TestSuite) { + + TestSuite suite = (TestSuite)element; + + //TODO check if there has been an error, a failure... + + icon = "tsuite.gif"; + + } else if(element instanceof TestCase) { + + TestCase test = (TestCase)element; + + if(test.isError()) + icon = "testerr.gif"; + else if(test.isFailure()) + icon = "testfail.gif"; + else if(test.isPass()) + icon = "testok.gif"; + + } + + + ImageDescriptor descriptor = ImageDescriptor.createFromURL(new URL("file://" + iconsPath + "//" + icon)); + image = descriptor.createImage(); + + } catch (MalformedURLException e) { + + e.printStackTrace(); + image = ImageDescriptor.getMissingImageDescriptor().createImage(); + } + + + + + + return image; + + } + +} diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestSuite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestSuite.java deleted file mode 100644 index faced9d..0000000 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestSuite.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Created on Jul 31, 2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package net.sourceforge.phpeclipse.phpunit; - -import java.util.Vector; - -/** - * @author Ali Echihabi - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class TestSuite { - - private Vector testCases; - private String name; - private String id; - - public void addTestCase(TestCase test) { - - } - - public void removeTestCase(TestCase test) {} - - public boolean contains(TestCase test) { - return false; - } - - - -} diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java index bfb6799..2e1c39c 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java @@ -6,10 +6,17 @@ */ package net.sourceforge.phpeclipse.phpunit.actions; +import java.io.IOException; + +import net.sourceforge.phpeclipse.phpunit.PHPUnitView; + +import org.eclipse.core.resources.IFile; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Item; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.views.navigator.ResourceNavigator; /** * @author Ali Echihabi @@ -19,19 +26,60 @@ import org.eclipse.ui.IWorkbenchPart; */ public class RunTestsAction implements IObjectActionDelegate { + + + /* (non-Javadoc) * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */ public void setActivePart(IAction action, IWorkbenchPart targetPart) { // TODO Auto-generated method stub + System.out.println(targetPart.getTitle()); + ResourceNavigator nav = (ResourceNavigator)targetPart; + + Item selectedItem = nav.getViewer().getTree().getSelection()[0]; + + Object d = selectedItem.getData(); +// +// try { +// +// IFile data = (IFile) selectedItem.getData(); +// +// } +// catch(Exception e) { +// +// e.printStackTrace(); +// +// } +// + + + +// Shell shell = PHPUnitPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); +// +// if(shell instanceof IStructuredSelection) { +// +// Object testObj = ((IStructuredSelection) ) +// } +// + + + } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { - // TODO Auto-generated method stub + + try { + PHPUnitView.getDefault().startTests(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestCase.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestCase.java new file mode 100644 index 0000000..7812b67 --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestCase.java @@ -0,0 +1,131 @@ +/* + * Created on Jul 31, 2004 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package net.sourceforge.phpeclipse.phpunit.testpool; + + +/** + * @author Ali Echihabi + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class TestCase { + + public static final String PASS = "PASS"; + public static final String FAIL = "FAIL"; + public static final String ERROR = "ERROR"; + + + private TestSuite parentSuite; + + + + /** + * @param testName + * @param testID + */ + public TestCase(String testName, String testID) { + + this.testName = testName; + this.testID = testID; + } + + + String testName; + String testID; + String verdict; + + /** + * @return + */ + public String getTestID() { + return testID; + } + + /** + * @return + */ + public String getTestName() { + return testName; + } + + /** + * @return + */ + public String getVerdict() { + return verdict; + } + + /** + * @param string + */ + public void setTestID(String string) { + testID = string; + } + + /** + * @param string + */ + public void setTestName(String string) { + testName = string; + } + + /** + * @param string + */ + public void setVerdict(String string) { + verdict = string; + + + + + + } + + /** + * @param suite + */ + public void setParentSuite(TestSuite suite) { + this.parentSuite = suite; + + } + + /** + * @return + */ + public Object getParentSuite() { + + return parentSuite; + } + + /** + * @return + */ + public boolean isError() { + + return getVerdict().equals(TestCase.ERROR); + } + + /** + * @return + */ + public boolean isFailure() { + + return getVerdict().equals(TestCase.FAIL); + + } + + /** + * @return + */ + public boolean isPass() { + + return getVerdict().equals(TestCase.PASS); + + } + +} diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestPool.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestPool.java new file mode 100644 index 0000000..008cb3d --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestPool.java @@ -0,0 +1,180 @@ +/* + * Created on Jul 31, 2004 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package net.sourceforge.phpeclipse.phpunit.testpool; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Vector; + + +/** + * @author Ali Echihabi + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class TestPool { + + //private TestSuite currentParentTestSuite; + private HashMap tests; + private TestSuite root; + private TestSuite currentTestSuite; + + + /** + * + */ + public TestPool(String rootTitle) { + + tests = new HashMap(); + root = new TestSuite(rootTitle, "-1", 0); + + currentTestSuite = root; + + } + + /** + * @param test + */ + public void addTest(TestCase test) { + + tests.put(test.getTestID(), test); + + currentTestSuite.addTestCase(test); + + + //if we run all tests. then this is the end of this test suite. + if( currentTestSuite != root && currentTestSuite.isFinished()) { + + currentTestSuite = currentTestSuite.getParent(); + + } + + } + + /** + * @param suite + * @param numTestsRunSinceStartOfTestSuite + */ + public void addTestSuite(TestSuite suite) { + + //add as sibling + currentTestSuite.addTestSuite(suite); + suite.setParent(currentTestSuite); + + currentTestSuite = suite; + } + + /** + * @return + */ + public TestSuite getRoot() { + + return root; + } + + /** + * @param r + */ + public void setRoot(TestSuite r) { + this.root = r; + } + + + + /** + * @param testID + * @return + */ + public TestCase getTest(String testID) { + + return (TestCase) tests.get(testID); + } + + public String toString() { + + String string = ""; + + TestSuite node = root; + + string = root.toString(); + + return string; + + } + + private int countSuiteExpectedTests(TestSuite suite) { + + int total = 0; + + total += suite.getNumTestCasesExpected(); + + for(int i = 0; i < suite.getTestSuites().size(); i++) + total += countSuiteExpectedTests((TestSuite) suite.getTestSuites().elementAt(i)); + + return total; + + } + + public int getNumTestsOverall() { + + return countSuiteExpectedTests(root); + + } + + public int getNumTestsRun() { + + return tests.size(); + + + } + + public int getNumFailures() { + + int total = 0; + + Iterator i = tests.keySet().iterator(); + String key = ""; + while (i.hasNext()) { + + + key = (String) i.next(); + TestCase element = (TestCase) tests.get(key); + + + if(element.isFailure()) + total++; + + } + + return total; + } + + public int getNumErrors() { + + int total = 0; + +// Iterator i = tests.keySet().iterator(); +// String key = ""; +// while (i.hasNext()) { +// +// +// key = (String) i.next(); +// TestCase element = (TestCase) tests.get(key); +// +// if(element.isError()) +// total++; +// +// } + + return total; + + } + + + +} diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestSuite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestSuite.java new file mode 100644 index 0000000..9d565da --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestSuite.java @@ -0,0 +1,206 @@ +/* + * Created on Jul 31, 2004 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package net.sourceforge.phpeclipse.phpunit.testpool; + +import java.util.Vector; + +/** + * @author Ali Echihabi + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class TestSuite { + + + + private Vector testCases; // current or actual. + private Vector testSuites; // current or actual. + private String name; + private String id; + private int numTestCasesExpected; //expected + private int numTestCasesRunSoFar; + TestSuite parent; + + /** + * @param name + * @param testID + * @param testCount + */ + public TestSuite(String name, String testID, int testCount) { + + this.parent = null; + this.id = testID; + this.name = name; + this.numTestCasesExpected = testCount; + + testCases = new Vector(); + testSuites = new Vector(); + + } + + /** + * @param name + * @param testID + * @param testCount + */ + public TestSuite(TestSuite parent, String name, String testID, int testCount) { + + this.parent = parent; + this.id = testID; + this.name = name; + this.numTestCasesExpected = testCount; + + testCases = new Vector(); + testSuites = new Vector(); + } + + public void addTestCase(TestCase test) { + testCases.addElement(test); + test.setParentSuite(this); + numTestCasesRunSoFar++; + } + + public void removeTestCase(TestCase test) {} + + public boolean contains(TestCase test) { + + return false; + + } + + public String toString() { + + String string = ""; + + //print test cases. + TestCase tc = null; + for(int i = 0; i < testCases.size(); i++) { + + tc = (TestCase) testCases.elementAt(i); + string += " - " + tc.getTestID() + ", " + tc.getTestName() + "\n"; + + + } + + for(int i = 0; i < testSuites.size(); i++) + string += ((TestSuite) testSuites.elementAt(i)).toString(); + + //print its own test suites. + return string; + } + + /** + * @return + */ + public String getId() { + return id; + } + + /** + * @return + */ + public String getName() { + return name; + } + + /** + * @return + */ + public int getNumTestCasesExpected() { + return numTestCasesExpected; + } + + /** + * @param string + */ + public void setId(String string) { + id = string; + } + + /** + * @param string + */ + public void setName(String string) { + name = string; + } + + /** + * @param i + */ + public void setNumTestCasesExpected(int i) { + numTestCasesExpected = i; + } + + /** + * @param suite + */ + public void addTestSuite(TestSuite suite) { + testSuites.addElement(suite); + + } + + /** + * @return + */ + public boolean isFinished() { + + return numTestCasesRunSoFar >= numTestCasesExpected; + + } + + /** + * @return + */ + public TestSuite getParent() { + return parent; + } + + /** + * @param suite + */ + public void setParent(TestSuite suite) { + parent = suite; + } + + /** + * @return + */ + public int getNumTestCases() { + + return testCases.size(); + } + + /** + * @return + */ + public Vector getTestCases() { + return testCases; + } + + /** + * @return + */ + public Vector getTestSuites() { + return testSuites; + } + + /** + * @param vector + */ + public void setTestCases(Vector vector) { + testCases = vector; + } + + /** + * @param vector + */ + public void setTestSuites(Vector vector) { + testSuites = vector; + } + +} -- 1.7.1