Permalink
Browse files

Adding code coverage toggling to CakeBaseReporter.

Updating CodeCoverageManager method use in CakeTestSuiteDispatcher.
  • Loading branch information...
1 parent da26124 commit d7164c416e27e762ba6973c82b57a68ff0fc04b1 @markstory markstory committed Jan 10, 2010
Showing with 31 additions and 2 deletions.
  1. +2 −2 cake/tests/lib/cake_test_suite_dispatcher.php
  2. +29 −0 cake/tests/lib/reporter/cake_base_reporter.php
@@ -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);
}
@@ -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);
}
@@ -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.
@@ -118,6 +119,34 @@ function 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.
*

0 comments on commit d7164c4

Please sign in to comment.