From a7b0b4971bb14df3cd35a3cd5a04c0f83df5be1c Mon Sep 17 00:00:00 2001 From: shleh Date: Sat, 18 Sep 2004 05:00:37 +0000 Subject: [PATCH] commented out code responsible for exceptions. now showing correct suite names and test names. --- .../phpeclipse/phpunit/PHPUnitView.java | 58 ++++++++++++-------- .../phpeclipse/phpunit/TestPoolLabelProvider.java | 15 ++++-- .../phpeclipse/phpunit/XMLReportHandler.java | 8 +++- .../phpeclipse/phpunit/testpool/TestCase.java | 19 ++++--- .../phpeclipse/phpunit/testpool/TestPool.java | 42 +++++---------- 5 files changed, 76 insertions(+), 66 deletions(-) diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java index 656610d..9f388dd 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java @@ -17,17 +17,11 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; import org.eclipse.ui.IActionBars; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; /** @@ -77,14 +71,18 @@ public class PHPUnitView extends ViewPart { private ProgressInfoComposite progressInfoComposite; private ResultsInfoComposite resultsInfoComposite; - private SettingsInfoComposite settingsInfoComposite; //TODO: move somewhere else, launcher, wizard or preferences. - + //private SettingsInfoComposite settingsInfoComposite; //TODO: move somewhere else, launcher, wizard or preferences. + private FileDialog dialog; + + private String testSuiteToRun = ""; public PHPUnitView() { if(view == null) view = this; + + } @@ -98,6 +96,8 @@ public class PHPUnitView extends ViewPart { //parent.setLayout(new FillLayout(SWT.VERTICAL)); + dialog = new FileDialog(parent.getShell()); + GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; @@ -121,7 +121,7 @@ public class PHPUnitView extends ViewPart { //build the settings composite //buildSettingsComposite(parent); - settingsInfoComposite = new SettingsInfoComposite(parent, SWT.NONE); + //settingsInfoComposite = new SettingsInfoComposite(parent, SWT.NONE); // startButton = new Button(parent, SWT.CENTER); @@ -192,7 +192,7 @@ public class PHPUnitView extends ViewPart { public void run() { - settingsInfoComposite.showFileDialog(); + testSuiteToRun = dialog.open(); } }; selectTestAction.setText("Select Test Suite"); @@ -214,9 +214,12 @@ public class PHPUnitView extends ViewPart { public void run() { - String testFile = settingsInfoComposite.getTestSuite(); + try { - startTests(testFile); + if(testSuiteToRun == null || testSuiteToRun == "") + return; + + startTests(testSuiteToRun); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -318,6 +321,7 @@ public class PHPUnitView extends ViewPart { 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"); @@ -349,6 +347,12 @@ public class PHPUnitView extends ViewPart { out.write("" + "\n"); out.write("" + "\n"); + out.write("$output = ob_get_contents();" + "\n"); + out.write("$fileHandle = fopen('c:/tmp/phpOut.txt');" + "\n"); + out.write("fclose($fileHandle);" + "\n"); + + + out.write("ob_end();" + "\n"); out.write("?>" + "\n"); out.flush(); @@ -408,10 +412,8 @@ public class PHPUnitView extends ViewPart { * @param testID */ public void handleCommand( - String command, - String testCount, - String testID) { - + String command, String[] args) { + if (command.equals("startAll")) { @@ -420,13 +422,21 @@ public class PHPUnitView extends ViewPart { } else if (command.equals("testSuiteStarted")) { + String testID = args[0]; + String testCount = args[1]; + //createNewTestSuite("TestSuiteName: " + testID, testID, new Integer(testCount).intValue()); TestSuite suite = new TestSuite("TestSuiteName: " + testID, testID, new Integer(testCount).intValue()); testPool.addTestSuite(suite); } else if (command.equals("testStarted")) { - testPool.addTest(new TestCase("TestName: " + testID, testID)); + String testID = args[0]; + String testCount = args[1]; + String testName = args[2]; + String parentTestSuiteName = args[3]; + + testPool.addTest(new TestCase(testID, testName, parentTestSuiteName)); } else if (command.equals("testFINISHED")) { 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 index 6977a6d..344bb08 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java @@ -29,14 +29,21 @@ public class TestPoolLabelProvider extends LabelProvider { public String getText(Object element) { + String text = ""; + if(element instanceof TestSuite) return ((TestSuite)element).getName(); - else if(element instanceof TestCase) - return ((TestCase)element).getTestName(); - else - return "UNKNOWN ELEMENT TYPE"; + else if(element instanceof TestCase) { + text = ((TestCase)element).getTestName(); + + //has the form: TESTSUITENAME_TESTNAME + + } + else + text = "UNKNOWN ELEMENT TYPE"; + return text; } diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/XMLReportHandler.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/XMLReportHandler.java index c81e518..69ab8e0 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/XMLReportHandler.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/XMLReportHandler.java @@ -22,6 +22,8 @@ public class XMLReportHandler extends DefaultHandler { private String currentCommand; private String currentTestCount; private String currentTestID; + private String currentTestName; + private String currentTestParentTestSuiteName; private void doAsyncRunnable(Runnable runnable) { @@ -102,12 +104,16 @@ public class XMLReportHandler extends DefaultHandler { currentCommand = attributes.getValue("command"); currentTestCount = attributes.getValue("testCount"); currentTestID = attributes.getValue("testID"); + currentTestName = attributes.getValue("testName"); + currentTestParentTestSuiteName = attributes.getValue("parentTestSuiteName"); doAsyncRunnable(new Runnable() { public void run() { - view.handleCommand(currentCommand, currentTestCount, currentTestID); + //view.handleCommand(currentCommand, currentTestCount, currentTestID, ); + view.handleCommand(currentCommand, new String[] {currentTestID, currentTestCount, currentTestName, currentTestParentTestSuiteName}); + } }); 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 index 7812b67..5d5891a 100644 --- 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 @@ -21,6 +21,11 @@ public class TestCase { private TestSuite parentSuite; + private String testName; + private String testID; + private String verdict; + private String parentTestSuiteName; + @@ -28,16 +33,14 @@ public class TestCase { * @param testName * @param testID */ - public TestCase(String testName, String testID) { + public TestCase(String testID, String testName, String parentTestSuiteName) { this.testName = testName; this.testID = testID; + this.parentTestSuiteName = parentTestSuiteName; } - String testName; - String testID; - String verdict; /** * @return @@ -65,8 +68,11 @@ public class TestCase { */ public void setTestID(String string) { testID = string; + } + + /** * @param string */ @@ -80,10 +86,6 @@ public class TestCase { public void setVerdict(String string) { verdict = string; - - - - } /** @@ -91,6 +93,7 @@ public class TestCase { */ public void setParentSuite(TestSuite suite) { this.parentSuite = suite; + suite.setName(parentTestSuiteName); } 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 index a8e5e6c..4e631ee 100644 --- 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 @@ -114,22 +114,6 @@ public class TestPool { } -// This recursion is done at the php side (report generation) - -// 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)); -// -// System.out.println("total: " + total); -// -// return total; -// -// } public int getNumTestsOverall() { @@ -150,19 +134,19 @@ public class TestPool { 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++; - - } +// 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; } -- 1.7.1