Updating code coverage tools to use raw data which includes dead and uncovered line data.

This commit is contained in:
Mark Story 2010-05-09 01:15:57 -04:00
parent 9a20a2344b
commit 75d7146bd0
3 changed files with 6 additions and 4 deletions

View file

@ -120,7 +120,7 @@ class HtmlCoverageReport {
public function filterCoverageDataByPath($path) {
$files = array();
foreach ($this->_rawCoverage as $testRun) {
foreach ($testRun['files'] as $filename => $fileCoverage) {
foreach ($testRun['data'] as $filename => $fileCoverage) {
if (strpos($filename, $path) !== 0) {
continue;
}
@ -136,6 +136,7 @@ class HtmlCoverageReport {
}
}
}
ksort($files);
return $files;
}
@ -214,7 +215,7 @@ class HtmlCoverageReport {
$diff[] = $this->_paintLine($line, $lineno, $class);
}
$percentCovered = round($covered / $total, 2);
$percentCovered = round(100 * $covered / $total, 2);
$output .= $this->coverageHeader($filename, $percentCovered);
$output .= implode("", $diff);
@ -243,6 +244,7 @@ class HtmlCoverageReport {
* @return void
*/
public function coverageHeader($filename, $percent) {
$filename = basename($filename);
return <<<HTML
<h2>$filename Code coverage: $percent%</h2>
<div class="code-coverage-results">

View file

@ -176,7 +176,7 @@ class CakeHtmlReporter extends CakeBaseReporter implements PHPUnit_Framework_Tes
echo $this->_paintLinks();
echo '</div>';
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
$coverage = $result->getCodeCoverageInformation();
$coverage = $result->getRawCodeCoverageInformation();
echo $this->paintCoverage($coverage);
}
$this->paintDocumentEnd();

View file

@ -162,7 +162,7 @@ class TestManager {
*/
protected function run($reporter, $codeCoverage = false) {
$result = new PHPUnit_Framework_TestResult;
$result->collectCodeCoverageInformation($codeCoverage);
$result->collectRawCodeCoverageInformation($codeCoverage);
$result->addListener($reporter);
$reporter->paintHeader();
$this->getTestSuite()->run($result);