Changeset 2288

Show
Ignore:
Timestamp:
03/12/2008 10:16:18 AM (7 months ago)
Author:
Geert
Message:

Fix #477

Location:
trunk/modules/unit_test
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/unit_test/i18n/en_US/unit_test.php

    r2278 r2288  
    88        'test_class_extends'   => '%s must extend Unit_Test_Case.', 
    99        'no_tests_found'       => 'No tests found', 
    10         'stats'                => 'Passed: %s / %s', 
    1110        'passed'               => 'Passed', 
    1211        'failed'               => 'Failed', 
     12        'error'                => 'Error', 
     13        'errors'               => 'Errors', 
    1314        'line'                 => 'line', 
    1415        'assert_true'          => 'Expected (boolean) TRUE, but was (%s) %s.', 
  • trunk/modules/unit_test/libraries/Unit_Test.php

    r2283 r2288  
    8585                                // Initialize test class results and stats 
    8686                                $this->results[$class] = array(); 
    87                                 $this->stats[$class] = array('passed' => 0, 'failed' => 0); 
     87                                $this->stats[$class] = array('passed' => 0, 'failed' => 0, 'errors' => 0); 
    8888 
    8989                                // Loop through all the class methods 
     
    122122                                                $this->stats[$class]['failed']++; 
    123123                                        } 
     124                                        catch (Exception $e) 
     125                                        { 
     126                                                // Test error 
     127                                                $this->results[$class][$method_name] = $e; 
     128                                                $this->stats[$class]['errors']++; 
     129                                        } 
    124130 
    125131                                        // Run teardown method 
  • trunk/modules/unit_test/tests/Example_Test.php

    r2270 r2288  
    6969        } 
    7070 
     71        public function error_test() 
     72        { 
     73                throw new Exception; 
     74        } 
     75 
    7176} 
  • trunk/modules/unit_test/views/kohana_unit_test.php

    r2283 r2288  
    8080        background-color: #FFD0D0; 
    8181} 
     82#kohana-unit-test .k-error 
     83{ 
     84        background-color: #FFFFE0; 
     85} 
     86#kohana-unit-test .k-altrow .k-error 
     87{ 
     88        background-color: #FFFFD1; 
     89} 
    8290</style> 
    8391 
     
    95103                        <th><?php echo $class ?></th> 
    96104                        <th class="k-stats"> 
    97                                 <?php echo Kohana::lang('unit_test.stats', $stats[$class]['passed'], array_sum($stats[$class])) ?> 
     105                                <?php echo Kohana::lang('unit_test.passed'), ': ', $stats[$class]['passed'] ?>, 
     106                                <?php echo Kohana::lang('unit_test.failed'), ': ', $stats[$class]['failed'] ?>, 
     107                                <?php echo Kohana::lang('unit_test.errors'), ': ', $stats[$class]['errors'] ?> 
    98108                        </th> 
    99109                </tr> 
     
    135145                                                </td> 
    136146 
     147                                        <?php elseif ($result instanceof Exception): ?> 
     148 
     149                                                <td class="k-error"> 
     150                                                        <strong><?php echo Kohana::lang('unit_test.error') ?></strong> 
     151                                                        <pre><?php echo html::specialchars($result->getMessage()) ?></pre> 
     152                                                        <?php echo html::specialchars($result->getFile()) ?> (<?php echo Kohana::lang('unit_test.line') ?>&nbsp;<?php echo $result->getLine() ?>) 
     153                                                </td> 
     154 
    137155                                        <?php endif ?> 
    138156