Changeset 275

Show
Ignore:
Timestamp:
10/31/07 08:01:03 (9 months ago)
Author:
mrook
Message:

#151 - Add support for grouping of tests (patch by Dirk Thomas)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.3/classes/phing/tasks/ext/phpunit/PHPUnitTask.php

    r255 r275  
    4545        private $testfailed = false; 
    4646        private $codecoverage = false; 
     47        private $groups = array(); 
     48        private $excludeGroups = array(); 
    4749 
    4850        /** 
     
    7981                { 
    8082                        PHPUnitUtil::$installedVersion = 3; 
     83                        if (version_compare($version, "3.2.0") >= 0) 
     84                        { 
     85                                PHPUnitUtil::$installedMinorVersion = 2; 
     86                        } 
    8187                } 
    8288                else 
     
    152158        { 
    153159                $this->codecoverage = $codecoverage; 
     160        } 
     161 
     162        function setGroups($groups) 
     163        { 
     164                if (PHPUnitUtil::$installedVersion < 3 || (PHPUnitUtil::$installedVersion == 3 && PHPUnitUtil::$installedMinorVersion < 2)) 
     165                { 
     166                        $this->log("The 'groups' attribute is only available with PHPUnit 3.2.0 or newer", Project::MSG_WARN); 
     167                } 
     168                $token = ' ,;'; 
     169                $this->groups = array(); 
     170                $tok = strtok($groups, $token); 
     171                while ($tok !== false) { 
     172                        $this->groups[] = $tok; 
     173                        $tok = strtok($token); 
     174                } 
     175        } 
     176 
     177        function setExcludeGroups($excludeGroups) 
     178        { 
     179                if (PHPUnitUtil::$installedVersion < 3 || (PHPUnitUtil::$installedVersion == 3 && PHPUnitUtil::$installedMinorVersion < 2)) 
     180                { 
     181                        $this->log("The 'excludeGroups' attribute is only available with PHPUnit 3.2.0 or newer", Project::MSG_WARN); 
     182                } 
     183                $token = ' ,;'; 
     184                $this->excludeGroups = array(); 
     185                $tok = strtok($groups, $token); 
     186                while ($tok !== false) { 
     187                        $this->excludeGroups[] = $tok; 
     188                        $tok = strtok($token); 
     189                } 
    154190        } 
    155191 
     
    256292        private function execute($suite) 
    257293        { 
    258                 $runner = new PHPUnitTestRunner($suite, $this->project); 
     294                $runner = new PHPUnitTestRunner($suite, $this->project, $this->groups, $this->excludeGroups); 
    259295                 
    260296                $runner->setCodecoverage($this->codecoverage); 
  • branches/2.3/classes/phing/tasks/ext/phpunit/PHPUnitTestRunner.php

    r189 r275  
    4747        private $project = NULL; 
    4848 
    49         function __construct($suite, Project $project) 
     49        private $groups = array(); 
     50        private $excludeGroups = array(); 
     51 
     52        function __construct($suite, Project $project, $groups = array(), $excludeGroups = array()) 
    5053        { 
    5154                $this->suite = $suite; 
    5255                $this->project = $project; 
     56                $this->groups = $groups; 
     57                $this->excludeGroups = $excludeGroups; 
    5358                $this->retCode = self::SUCCESS; 
    5459        } 
     
    8994                } 
    9095 
    91                 $this->suite->run($res); 
     96                $this->suite->run($res, false, $this->groups, $this->excludeGroups); 
    9297                 
    9398                if ($this->codecoverage) 
  • branches/2.3/classes/phing/tasks/ext/phpunit/PHPUnitUtil.php

    r148 r275  
    3131{ 
    3232        /** 
    33          * Installed PHPUnit version 
     33         * Installed PHPUnit major version 
    3434         */ 
    3535        public static $installedVersion = 2; 
     36         
     37        /** 
     38         * Installed PHPUnit minor version 
     39         */ 
     40        public static $installedMinorVersion = 0; 
    3641         
    3742        protected static $definedClasses = array(); 
  • trunk/classes/phing/tasks/ext/phpunit/PHPUnitTask.php

    r254 r275  
    4545        private $testfailed = false; 
    4646        private $codecoverage = false; 
     47        private $groups = array(); 
     48        private $excludeGroups = array(); 
    4749 
    4850        /** 
     
    7981                { 
    8082                        PHPUnitUtil::$installedVersion = 3; 
     83                        if (version_compare($version, "3.2.0") >= 0) 
     84                        { 
     85                                PHPUnitUtil::$installedMinorVersion = 2; 
     86                        } 
    8187                } 
    8288                else 
     
    152158        { 
    153159                $this->codecoverage = $codecoverage; 
     160        } 
     161 
     162        function setGroups($groups) 
     163        { 
     164                if (PHPUnitUtil::$installedVersion < 3 || (PHPUnitUtil::$installedVersion == 3 && PHPUnitUtil::$installedMinorVersion < 2)) 
     165                { 
     166                        $this->log("The 'groups' attribute is only available with PHPUnit 3.2.0 or newer", Project::MSG_WARN); 
     167                } 
     168                $token = ' ,;'; 
     169                $this->groups = array(); 
     170                $tok = strtok($groups, $token); 
     171                while ($tok !== false) { 
     172                        $this->groups[] = $tok; 
     173                        $tok = strtok($token); 
     174                } 
     175        } 
     176 
     177        function setExcludeGroups($excludeGroups) 
     178        { 
     179                if (PHPUnitUtil::$installedVersion < 3 || (PHPUnitUtil::$installedVersion == 3 && PHPUnitUtil::$installedMinorVersion < 2)) 
     180                { 
     181                        $this->log("The 'excludeGroups' attribute is only available with PHPUnit 3.2.0 or newer", Project::MSG_WARN); 
     182                } 
     183                $token = ' ,;'; 
     184                $this->excludeGroups = array(); 
     185                $tok = strtok($groups, $token); 
     186                while ($tok !== false) { 
     187                        $this->excludeGroups[] = $tok; 
     188                        $tok = strtok($token); 
     189                } 
    154190        } 
    155191 
     
    256292        private function execute($suite) 
    257293        { 
    258                 $runner = new PHPUnitTestRunner($suite, $this->project); 
     294                $runner = new PHPUnitTestRunner($suite, $this->project, $this->groups, $this->excludeGroups); 
    259295                 
    260296                $runner->setCodecoverage($this->codecoverage); 
  • trunk/classes/phing/tasks/ext/phpunit/PHPUnitTestRunner.php

    r189 r275  
    4747        private $project = NULL; 
    4848 
    49         function __construct($suite, Project $project) 
     49        private $groups = array(); 
     50        private $excludeGroups = array(); 
     51 
     52        function __construct($suite, Project $project, $groups = array(), $excludeGroups = array()) 
    5053        { 
    5154                $this->suite = $suite; 
    5255                $this->project = $project; 
     56                $this->groups = $groups; 
     57                $this->excludeGroups = $excludeGroups; 
    5358                $this->retCode = self::SUCCESS; 
    5459        } 
     
    8994                } 
    9095 
    91                 $this->suite->run($res); 
     96                $this->suite->run($res, false, $this->groups, $this->excludeGroups); 
    9297                 
    9398                if ($this->codecoverage) 
  • trunk/classes/phing/tasks/ext/phpunit/PHPUnitUtil.php

    r148 r275  
    3131{ 
    3232        /** 
    33          * Installed PHPUnit version 
     33         * Installed PHPUnit major version 
    3434         */ 
    3535        public static $installedVersion = 2; 
     36         
     37        /** 
     38         * Installed PHPUnit minor version 
     39         */ 
     40        public static $installedMinorVersion = 0; 
    3641         
    3742        protected static $definedClasses = array();