diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 7ba5f7596..445636693 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -227,7 +227,7 @@ class CakeTestSuiteDispatcher { $this->Manager->runAllTests($Reporter); } else { if ($this->params['codeCoverage']) { - CodeCoverageManager::start($this->params['group'], $Reporter); + CodeCoverageManager::init($this->params['group'], $Reporter); } $this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter); } @@ -241,7 +241,7 @@ class CakeTestSuiteDispatcher { function _runTestCase() { $Reporter =& CakeTestSuiteDispatcher::getReporter(); if ($this->params['codeCoverage']) { - CodeCoverageManager::start($this->params['case'], $Reporter); + CodeCoverageManager::init($this->params['case'], $Reporter); } $this->Manager->runTestCase($this->params['case'], $Reporter); } diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 7a12fd3ae..c634f89d0 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -75,6 +75,7 @@ class CakeBaseReporter extends SimpleReporter { * - plugin - Plugin test being run? * - app - App test being run. * - case - The case being run + * - codeCoverage - Whether the case/group being run is being code covered. * * @param string $charset The character set to output with. Defaults to UTF-8 * @param array $params Array of request parameters the reporter should use. See above. @@ -117,6 +118,34 @@ class CakeBaseReporter extends SimpleReporter { parent::paintGroupEnd($test_name); } +/** + * Paints the beginning of a test method being run. This is used + * to start/resume the code coverage tool. + * + * @param string $method The method name being run. + * @return void + */ + function paintMethodStart($method) { + parent::paintMethodStart($method); + if (!empty($this->params['codeCoverage'])) { + CodeCoverageManager::start(); + } + } + +/** + * Paints the end of a test method being run. This is used + * to pause the collection of code coverage if its being used. + * + * @param string $method The name of the method being run. + * @return void + */ + function paintMethodEnd($method) { + parent::paintMethodEnd($method); + if (!empty($this->params['codeCoverage'])) { + CodeCoverageManager::stop(); + } + } + /** * Get the current time in microseconds. Similar to getMicrotime in basics.php * but in a separate function to reduce dependancies.