commented out code responsible for exceptions. now showing correct suite names and...
authorshleh <shleh>
Sat, 18 Sep 2004 05:00:37 +0000 (05:00 +0000)
committershleh <shleh>
Sat, 18 Sep 2004 05:00:37 +0000 (05:00 +0000)
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/XMLReportHandler.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestCase.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestPool.java

index 656610d..9f388dd 100644 (file)
@@ -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("<?php" + "\n");
+               out.write("ob_start();" + "\n");
                out.write("$path = \"C:/Documents and Settings/Ali Echihabi/My Documents/workspace.eclipse2.1/PHPUnit/phpunit\";" + "\n");
                out.write("include_once($path . \"/phpunit_test.php\");" + "\n");
                out.write("include_once $path . \"/socketTestResult.php\";" + "\n");
@@ -335,13 +339,7 @@ public class PHPUnitView extends ViewPart {
                out.write("$suite = new TestSuite();" + "\n");
                out.write("$suite->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")) {
 
index 6977a6d..344bb08 100644 (file)
@@ -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;
                
        }
 
index c81e518..69ab8e0 100644 (file)
@@ -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});           
+                                       
                                }                       
                        });
 
index 7812b67..5d5891a 100644 (file)
@@ -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);
                
        }
 
index a8e5e6c..4e631ee 100644 (file)
@@ -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;
        }