Skip to content

Commit

Permalink
Adding code coverage toggling to CakeBaseReporter.
Browse files Browse the repository at this point in the history
Updating CodeCoverageManager method use in CakeTestSuiteDispatcher.
  • Loading branch information
markstory committed Jan 10, 2010
1 parent da26124 commit d7164c4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cake/tests/lib/cake_test_suite_dispatcher.php
Expand Up @@ -227,7 +227,7 @@ function _runGroupTest() {
$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);
}
Expand All @@ -241,7 +241,7 @@ function _runGroupTest() {
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);
}
Expand Down
29 changes: 29 additions & 0 deletions cake/tests/lib/reporter/cake_base_reporter.php
Expand Up @@ -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.
Expand Down Expand Up @@ -117,6 +118,34 @@ function paintGroupEnd($test_name) {
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.
Expand Down

0 comments on commit d7164c4

Please sign in to comment.