Changeset 19522
- Timestamp:
- 06/24/09 21:57:30 (8 months ago)
- Files:
-
- branches/1.3/WHATS_NEW (modified) (1 diff)
- branches/1.3/lib/autoload/sfCoreAutoload.class.php (modified) (1 diff)
- branches/1.3/lib/task/symfony/sfSymfonyTestTask.class.php (modified) (2 diffs)
- branches/1.3/lib/task/test/sfTestAllTask.class.php (modified) (4 diffs)
- branches/1.3/lib/task/test/sfTestBaseTask.class.php (added)
- branches/1.3/lib/task/test/sfTestFunctionalTask.class.php (modified) (5 diffs)
- branches/1.3/lib/task/test/sfTestUnitTask.class.php (modified) (5 diffs)
- branches/1.3/test/other/fixtures/test/functional/result-harness.txt (modified) (1 diff)
- branches/1.3/test/other/fixtures/test/result-harness.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.3/WHATS_NEW
r19273 r19522 211 211 end(); 212 212 213 ### JUnit Compatible XML Output 214 215 The test tasks are now able to output a JUnit compatible XML file by using the 216 `--xml` option: 217 218 $ php symfony test:all --xml=log.xml 219 220 ### Easy Debugging 221 222 To ease the debugging when a test harness reports failed tests, you can now 223 pass the `--trace` option to have a detailed output about the failures: 224 225 $ php symfony test:all -t 226 213 227 Tasks 214 228 ----- branches/1.3/lib/autoload/sfCoreAutoload.class.php
r19273 r19522 410 410 'sfsymfonytesttask' => 'task/symfony/sfSymfonyTestTask.class.php', 411 411 'sftestalltask' => 'task/test/sfTestAllTask.class.php', 412 'sftestbasetask' => 'task/test/sfTestBaseTask.class.php', 412 413 'sftestcoveragetask' => 'task/test/sfTestCoverageTask.class.php', 413 414 'sftestfunctionaltask' => 'task/test/sfTestFunctionalTask.class.php', branches/1.3/lib/task/symfony/sfSymfonyTestTask.class.php
r18731 r19522 27 27 new sfCommandOption('update-autoloader', 'u', sfCommandOption::PARAMETER_NONE, 'Update the sfCoreAutoload class'), 28 28 new sfCommandOption('only-failed', 'f', sfCommandOption::PARAMETER_NONE, 'Only run tests that failed last time'), 29 new sfCommandOption('xml', null, sfCommandOption::PARAMETER_REQUIRED, 'The file name for the JUnit compatible XML log file'), 29 30 )); 30 31 … … 105 106 file_put_contents($statusFile, serialize($h->get_failed_files())); 106 107 108 if ($options['trace']) 109 { 110 $this->outputHarnessTrace($h); 111 } 112 113 if ($options['xml']) 114 { 115 file_put_contents($options['xml'], $h->to_xml()); 116 } 117 107 118 return $ret; 108 119 } 120 121 // master is at sfTestBaseTask 122 /** 123 * @see sfTestBaseTask::outputHarnessTrace() 124 */ 125 protected function outputHarnessTrace(lime_harness $h) 126 { 127 $xml = new SimpleXMLElement($h->to_xml()); 128 foreach ($xml as $testsuite) 129 { 130 if ($testsuite['failures']) 131 { 132 $new = true; 133 134 foreach ($testsuite->testcase as $testcase) 135 { 136 foreach ($testcase->failure as $failure) 137 { 138 if ($new) 139 { 140 $this->log(''); 141 $this->log($this->formatter->format($testsuite['file'], 'ERROR')); 142 $new = false; 143 } 144 145 $this->log($this->formatter->format(sprintf(' at %s line %s', $testcase['file'], $testcase['line']), 'COMMENT')); 146 $this->log($this->formatter->format(' '.$testcase['name'], 'INFO')); 147 $this->log($failure); 148 } 149 } 150 } 151 } 152 } 109 153 } branches/1.3/lib/task/test/sfTestAllTask.class.php
r18731 r19522 17 17 * @version SVN: $Id$ 18 18 */ 19 class sfTestAllTask extends sf BaseTask19 class sfTestAllTask extends sfTestBaseTask 20 20 { 21 21 /** … … 26 26 $this->addOptions(array( 27 27 new sfCommandOption('only-failed', 'f', sfCommandOption::PARAMETER_NONE, 'Only run tests that failed last time'), 28 )); 29 30 $this->addOptions(array( 31 new sfCommandOption('xml', null, sfCommandOption::PARAMETER_REQUIRED, 'The file name for the JUnit compatible XML log file'), 28 32 )); 29 33 … … 40 44 The task launches all tests found in [test/|COMMENT]. 41 45 42 If one or more test fail, you can try to fix the problem by launching 43 them by hand or with the [test:unit|COMMENT] and [test:functional|COMMENT] task. 46 If some tests fail, you can use the [--trace|COMMENT] option to have more 47 information about the failures: 48 49 [./symfony test:all -t|INFO] 50 51 Or you can also try to fix the problem by launching them by hand or with the 52 [test:unit|COMMENT] and [test:functional|COMMENT] task. 53 54 Use the [--only-failed|COMMENT] option to force the task to only execute tests 55 that failed during the previous run: 56 57 [./symfony test:all --only-failed|INFO] 58 59 Here is how it works: the first time, all tests are run as usual. But for 60 subsequent test runs, only tests that failed last time are executed. As you 61 fix your code, some tests will pass, and will be removed from subsequent runs. 62 When all tests pass again, the full test suite is run... you can then rinse 63 and repeat. 64 65 The task can output a JUnit compatible XML log file with the [--xml|COMMENT] 66 options: 67 68 [./symfony test:all --xml=log.xml|INFO] 44 69 EOF; 45 70 } … … 83 108 file_put_contents($statusFile, serialize($h->get_failed_files())); 84 109 110 if ($options['trace']) 111 { 112 $this->outputHarnessTrace($h); 113 } 114 115 if ($options['xml']) 116 { 117 file_put_contents($options['xml'], $h->to_xml()); 118 } 119 85 120 return $ret; 86 121 } branches/1.3/lib/task/test/sfTestFunctionalTask.class.php
r18731 r19522 17 17 * @version SVN: $Id$ 18 18 */ 19 class sfTestFunctionalTask extends sf BaseTask19 class sfTestFunctionalTask extends sfTestBaseTask 20 20 { 21 21 /** … … 27 27 new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'), 28 28 new sfCommandArgument('controller', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY, 'The controller name'), 29 )); 30 31 $this->addOptions(array( 32 new sfCommandOption('xml', null, sfCommandOption::PARAMETER_REQUIRED, 'The file name for the JUnit compatible XML log file'), 29 33 )); 30 34 … … 42 46 The task launches all tests found in [test/functional/%application%|COMMENT]. 43 47 48 If some tests fail, you can use the [--trace|COMMENT] option to have more 49 information about the failures: 50 51 [./symfony test:functional frontend -t|INFO] 52 44 53 You can launch all functional tests for a specific controller by 45 54 giving a controller name: … … 50 59 51 60 [./symfony test:functional frontend article comment|INFO] 61 62 The task can output a JUnit compatible XML log file with the [--xml|COMMENT] 63 options: 64 65 [./symfony test:functional --xml=log.xml|INFO] 52 66 EOF; 53 67 } … … 82 96 $h->register($finder->in($h->base_dir)); 83 97 84 return $h->run() ? 0 : 1; 98 $ret = $h->run() ? 0 : 1; 99 100 if ($options['trace']) 101 { 102 $this->outputHarnessTrace($h); 103 } 104 105 if ($options['xml']) 106 { 107 file_put_contents($options['xml'], $h->to_xml()); 108 } 109 110 return $ret; 85 111 } 86 112 } branches/1.3/lib/task/test/sfTestUnitTask.class.php
r18731 r19522 17 17 * @version SVN: $Id$ 18 18 */ 19 class sfTestUnitTask extends sf BaseTask19 class sfTestUnitTask extends sfTestBaseTask 20 20 { 21 21 /** … … 26 26 $this->addArguments(array( 27 27 new sfCommandArgument('name', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY, 'The test name'), 28 )); 29 30 $this->addOptions(array( 31 new sfCommandOption('xml', null, sfCommandOption::PARAMETER_REQUIRED, 'The file name for the JUnit compatible XML log file'), 28 32 )); 29 33 … … 40 44 The task launches all tests found in [test/unit|COMMENT]. 41 45 46 If some tests fail, you can use the [--trace|COMMENT] option to have more 47 information about the failures: 48 49 [./symfony test:unit -t|INFO] 50 42 51 You can launch unit tests for a specific name: 43 52 … … 47 56 48 57 [./symfony test:unit strtolower strtoupper|INFO] 58 59 The task can output a JUnit compatible XML log file with the [--xml|COMMENT] 60 options: 61 62 [./symfony test:unit --xml=log.xml|INFO] 49 63 EOF; 50 64 } … … 77 91 $h->register($finder->in($h->base_dir)); 78 92 79 return $h->run() ? 0 : 1; 93 $ret = $h->run() ? 0 : 1; 94 95 if ($options['trace']) 96 { 97 $this->outputHarnessTrace($h); 98 } 99 100 if ($options['xml']) 101 { 102 file_put_contents($options['xml'], $h->to_xml()); 103 } 104 105 return $ret; 80 106 } 81 107 } branches/1.3/test/other/fixtures/test/functional/result-harness.txt
r6882 r19522 4 4 Failed Test Stat Total Fail List of Failed 5 5 ------------------------------------------------------------------ 6 fooActionsTest 0 11 46 fooActionsTest 0 4 1 4 7 7 Failed 1/2 test scripts, 50.00% okay. 1/8 subtests failed, 87.50% okay. branches/1.3/test/other/fixtures/test/result-harness.txt
r6882 r19522 5 5 Failed Test Stat Total Fail List of Failed 6 6 ------------------------------------------------------------------ 7 tional/frontend/fooActionsTest 0 11 47 tional/frontend/fooActionsTest 0 4 1 4 8 8 Failed 1/3 test scripts, 66.67% okay. 1/9 subtests failed, 88.89% okay.

