Adding code coverage toggling to CakeBaseReporter.

Updating CodeCoverageManager method use in CakeTestSuiteDispatcher.
This commit is contained in:
Mark Story 2010-01-10 13:24:41 -05:00
parent da26124add
commit d7164c416e
2 changed files with 31 additions and 2 deletions

View file

@ -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);
}

View file

@ -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.