protected function doRun() { if (sizeof($this->getReports()) === 0) { $this->addDefaultReport(); } switch ($this->reportFormat) { case 'xml': case 'clover': $writer = new atoum\writers\file($this->reportOutputPathIsSet()->reportOutputPath); $report = new atoum\reports\asynchronous\clover(); $this->addReport($report->addWriter($writer)); break; case 'html': $field = new atoum\report\fields\runner\coverage\html('Code coverage', $this->reportOutputPathIsSet()->reportOutputPath); $field->setRootUrl('file://' . realpath(rtrim($this->reportOutputPathIsSet()->reportOutputPath, DIRECTORY_SEPARATOR)) . '/index.html'); current($this->getReports())->addField($field); break; case 'treemap': $field = new atoum\report\fields\runner\coverage\treemap('Code coverage treemap', $this->reportOutputPathIsSet()->reportOutputPath); $field->setTreemapUrl('file://' . realpath(rtrim($this->reportOutputPathIsSet()->reportOutputPath, DIRECTORY_SEPARATOR)) . '/index.html'); current($this->getReports())->addField($field); break; default: throw new exceptions\logic\invalidArgument('Invalid format for coverage report'); } return parent::doRun(); }
public function testSetResourcesDirectory() { $this->if($treemap = new testedClass(uniqid(), uniqid()))->then->object($treemap->setResourcesDirectory($directory = uniqid()))->isIdenticalTo($treemap)->string($treemap->getResourcesDirectory())->isEqualTo($directory)->object($treemap->setResourcesDirectory())->isIdenticalTo($treemap)->string($treemap->getResourcesDirectory())->isEqualTo(atoum\directory . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'coverage' . DIRECTORY_SEPARATOR . 'treemap'); }
public function configureCoverageTreemapField($coverageTreemapPath, $coverageReportUrl = null) { $coverageTreemapField = new coverage\treemap(isset($this->project) ? $this->project->getName() : 'Code coverage treemap', $coverageTreemapPath); $coverageTreemapField->setTreemapUrl($this->codeCoverageTreemapUrl ?: 'file://' . $coverageTreemapPath . '/index.html'); if ($coverageReportUrl !== null) { $coverageTreemapField->setHtmlReportBaseUrl($coverageReportUrl); } return $coverageTreemapField; }
} } my_mkdir($path); my_mkdir($path . DIRECTORY_SEPARATOR . 'cover'); my_mkdir($path . DIRECTORY_SEPARATOR . 'treemap'); $report = $script->addDefaultReport(); $runner->setBootstrapFile(__DIR__ . DIRECTORY_SEPARATOR . '.bootstrap.atoum.php'); $runner->addTestsFromDirectory(__DIR__ . DIRECTORY_SEPARATOR . 'website' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'units' . DIRECTORY_SEPARATOR); //$script->addDefaultReport(); $xunitWriter = new atoum\writers\file('build/atoum.xunit.xml'); $xunitReport = new atoum\reports\asynchronous\xunit(); $xunitReport->addWriter($xunitWriter); $runner->addReport($xunitReport); /* Please replace in next line /path/to/destination/directory by your destination directory path for html files. */ $coverageHtmlField = new atoum\report\fields\runner\coverage\html('markattaks', 'build/atoum/cover'); /* Please replace in next line http://url/of/web/site by the root url of your code coverage web site. */ $coverageHtmlField->setRootUrl('http://m2gl.deptinfo-st.univ-fcomte.fr:9080/jenkins/job/MarkAttacks%20(w-o%20Squash%20TA)/PHP_Coverage'); // Treemap (not mandatory) /* Please replace in next line /path/to/destination/directory by your destination directory path for html files. */ $coverageTreemapField = new atoum\report\fields\runner\coverage\treemap('markattaks', 'build/atoum/treemap'); /* Please replace in next line http://url/of/treemap by the root url of your treemap web site. */ $coverageTreemapField->setTreemapUrl('http://m2gl.deptinfo-st.univ-fcomte.fr:9080/jenkins/job/MarkAttacks%20(w-o%20Squash%20TA)/PHP_Coverage_treemap')->setHtmlReportBaseUrl($coverageHtmlField->getRootUrl()); $script->addDefaultReport()->addField($coverageHtmlField)->addField($coverageTreemapField);
<?php /* Sample atoum configuration file to have code coverage in html format and the treemap. Do "php path/to/test/file -c path/to/this/file" or "php path/to/atoum/scripts/runner.php -c path/to/this/file -f path/to/test/file" to use it. */ use mageekguy\atoum; // HTML /* Please replace in next line /path/to/destination/directory by your destination directory path for html files. */ $coverageHtmlField = new atoum\report\fields\runner\coverage\html('Queue Client', 'codeCoverage'); /* Please replace in next line http://url/of/web/site by the root url of your code coverage web site. */ $coverageHtmlField->setRootUrl('/'); // Treemap (not mandatory) /* Please replace in next line /path/to/destination/directory by your destination directory path for html files. */ $coverageTreemapField = new atoum\report\fields\runner\coverage\treemap('Queue Client', 'codeCoverage'); /* Please replace in next line http://url/of/treemap by the root url of your treemap web site. */ $coverageTreemapField->setTreemapUrl('')->setHtmlReportBaseUrl($coverageHtmlField->getRootUrl()); $script->addDefaultReport()->addField($coverageHtmlField)->addField($coverageTreemapField); $cloverWriter = new atoum\writers\file('coverage.xml'); $cloverReport = new atoum\reports\asynchronous\clover(); $cloverReport->addWriter($cloverWriter); $runner->addReport($cloverReport);