Changeset 1417 for branches

Show
Ignore:
Timestamp:
04/08/06 07:20:16 (3 years ago)
Author:
sdcosta
Message:

Tests are now grouped by category

Location:
branches/magpie-hacks/MagpieTests
Files:
1 added
3 modified
1 moved

Legend:

Unmodified
Added
Removed
  • branches/magpie-hacks/MagpieTests/README

    r1414 r1417  
    77 
    88The Magpie unit test files will be stored in  
    9 http://svn.gregarius.net/svn/branches/magpie-pirate-tests 
    10 Please download that branch into this directory to and point  
    11 your web browser to runTests.php 
     9http://svn.gregarius.net/svn/branches/magpie-hacks/ 
     10Please download that branch and point your web browser to runTests.php 
    1211 
    1312--Sameer 
  • branches/magpie-hacks/MagpieTests/rss_unitTest.inc

    r1414 r1417  
    11<?php 
    22 
    3 define('UNIT_TESTS_DIR_NAME', 'TestCases'); 
     3require_once('rss_testConstants.inc'); 
    44 
    55class RSSUnitTest { 
     
    1515     
    1616    function RSSUnitTest ($filename = "") { 
    17         $this->fileName = $filename; 
    18         $this->filePath = dirname(__FILE__) . DIR_SEP .  
    19                     UNIT_TESTS_DIR_NAME . DIR_SEP . $this->fileName; 
     17        $this->fileName = strtr($filename, array("." => "")); // do not allow periods in the filename 
     18        $this->filePath = dirname(__FILE__) . DIR_SEP . $this->fileName . ".xml"; 
    2019    } 
    2120     
  • branches/magpie-hacks/MagpieTests/runTests.php

    r1414 r1417  
    1919 
    2020require_once('../rss_fetch.inc'); 
     21require_once('rss_testConstants.inc'); 
    2122require_once('rss_unitTest.inc'); 
    2223     
     
    2728$fetchTestUrl = $thisScriptBaseUrl . "fetchTest.php" ; 
    2829 
     30$wellFormedTestCategories = glob(UNIT_TESTS_DIR_NAME . DIR_SEP . WELLFORMED_UNIT_TESTS_DIR_NAME  
     31                . DIR_SEP . "*", GLOB_ONLYDIR); 
     32$illFormedTestCategories = glob(UNIT_TESTS_DIR_NAME . DIR_SEP . ILLFORMED_UNIT_TESTS_DIR_NAME  
     33                . DIR_SEP . "*", GLOB_ONLYDIR); 
    2934 
    30 $tests = array(); 
    31 $tests[] = "Wellformed/date/item_pubDate.xml"; 
    32 $tests[] = "Wellformed/rss/item_title.xml"; 
     35$testCategories = array_merge($wellFormedTestCategories, $illFormedTestCategories); 
    3336 
    3437 
    3538echo "<html>\n<body>\n<table border=\"1\">\n"; 
    36 echo "<tr><th>Location</th><th>Description</th><th>Result</th>\n"; 
    37 foreach ($tests as $test) { 
    38     $_magpie_unitTest = new RSSUnitTest ($test); 
    39     echo "<tr>\n"; 
    40     echo "<td>\n"  
    41         ."<a href=\""  . $thisScriptBaseUrl . "TestCases/" . $test  
    42         ."\">" 
    43         .$test  
    44         ."</a>\n</td>\n"  
    45         ."<td>"   
    46         . htmlspecialchars($_magpie_unitTest->getDescription())  
    47         ."</td>\n"; 
     39//echo "<tr><th>Location</th><th>Description</th><th>Result</th>\n"; 
     40foreach ($testCategories as $testCategory) { 
     41     $tests = glob($testCategory . DIR_SEP . "*.xml"); 
     42     echo "<tr><th colspan=\"2\">" . $testCategory . "</th></tr>\n"; 
     43     $testCategory = substr($testCategory, strlen(UNIT_TESTS_DIR_NAME . DIR_SEP  
     44            . ILLFORMED_UNIT_TESTS_DIR_NAME . DIR_SEP)); 
    4845 
    49     $rss = fetch_rss($fetchTestUrl . "?testfile=" . $test); 
    50     echo "<td>\n";  
    51     if (assert($_magpie_unitTest->getExpect())){ 
    52         echo "<font color=\"green\">Test Passed</font>"; 
    53     }else{ 
    54         echo "<font color=\"red\">Test Failed</font>"; 
    55     } 
    56     echo "</td>\n</tr>";  
     46     foreach ($tests as $test) { 
     47        $test = substr($test, 0, - strlen(".xml")); // remove the .xml 
     48           $_magpie_unitTest = new RSSUnitTest ($test); 
     49           echo "<tr>\n"; 
     50           echo "<td>\n"  
     51            ."<a href=\""  . $thisScriptBaseUrl . "/" .  $test . ".xml" 
     52            ."\">" 
     53            . htmlspecialchars($_magpie_unitTest->getDescription())  
     54            ."</a>\n</td>\n"  
     55            ."</td>\n"; 
     56 
     57           $rss = fetch_rss($fetchTestUrl . "?testfile=" . $test); 
     58           echo "<td>\n";  
     59           if (assert($_magpie_unitTest->getExpect())){ 
     60            echo "<font color=\"green\">Test Passed</font>"; 
     61           }else{ 
     62            echo "<font color=\"red\">Test Failed</font>"; 
     63           } 
     64           echo "</td>\n</tr>";  
     65     } 
    5766} 
    5867echo "\n</table>\n</body>\n</html>";