Changeset 2278 for trunk/modules/unit_test/libraries/Unit_Test.php
- Timestamp:
- 03/10/2008 05:17:44 PM (9 months ago)
- Files:
-
- 1 modified
-
trunk/modules/unit_test/libraries/Unit_Test.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/unit_test/libraries/Unit_Test.php
r2275 r2278 12 12 class Unit_Test_Core { 13 13 14 // The path(s) to recursively scan for tests 14 15 protected $paths = array(); 16 17 // The results of all tests from every test class 15 18 protected $results = array(); 19 20 // Statistics for every test class 21 protected $stats = array(); 16 22 17 23 /** … … 61 67 throw new Kohana_Exception('unit_test.test_class_not_found', $class, $path); 62 68 63 // Instantiate test class results64 $this->results[$class] = array();65 66 69 // Reverse-engineer Test class 67 70 $reflector = new ReflectionClass($class); … … 70 73 if ( ! $reflector->isSubclassOf(new ReflectionClass('Unit_Test_Case'))) 71 74 throw new Kohana_Exception('unit_test.test_class_extends', $class); 75 76 // Initialize test class results and stats 77 $this->results[$class] = array(); 78 $this->stats[$class] = array('passed' => 0, 'failed' => 0); 72 79 73 80 // Loop through all the class methods … … 95 102 { 96 103 $object->$method_name(); 104 105 // Test passed 97 106 $this->results[$class][$method_name] = TRUE; 107 $this->stats[$class]['passed']++; 98 108 } 99 109 catch (Kohana_Unit_Test_Exception $e) 100 110 { 111 // Test failed 101 112 $this->results[$class][$method_name] = $e; 113 $this->stats[$class]['failed']++; 102 114 } 103 115 … … 122 134 public function report() 123 135 { 124 return empty($this->results) ? '' : View::factory('kohana_unit_test')->set('results', $this->results)->render(); 136 if (empty($this->results)) 137 return ''; 138 139 return View::factory('kohana_unit_test') 140 ->set('results', $this->results) 141 ->set('stats', $this->stats) 142 ->render(); 125 143 } 126 144
