示例#1
0
 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();
 }
示例#2
0
 public function testHandleEvent()
 {
     $this->if($adapter = new atoum\test\adapter())->if($adapter->extension_loaded = true)->and($report = new testedClass($adapter))->and($score = new \mock\mageekguy\atoum\score())->and($coverage = new \mock\mageekguy\atoum\score\coverage())->and($writer = new \mock\mageekguy\atoum\writers\file())->and($writer->getMockController()->write = $writer)->then->when(function () use($report, $writer) {
         $report->addWriter($writer)->handleEvent(atoum\runner::runStop, new \mageekguy\atoum\runner());
     })->mock($writer)->call('writeAsynchronousReport')->withArguments($report)->once()->and($adapter->time = 762476400)->and($adapter->uniqid = 'foo')->and($observable = new \mock\mageekguy\atoum\runner())->and($observable->getMockController()->getScore = $score)->and($score->getMockController()->getCoverage = $coverage)->and($coverage->getMockController()->getClasses = array())->and($filepath = join(DIRECTORY_SEPARATOR, array(__DIR__, 'clover', 'resources', '1.xml')))->and($report = new testedClass($adapter))->then->object($report->handleEvent(atoum\runner::runStop, $observable))->isIdenticalTo($report)->castToString($report)->isEqualToContentsOfFile($filepath)->if($coverage->getMockController()->getClasses = array())->and($classController = new mock\controller())->and($classController->disableMethodChecking())->and($classController->__construct = function () {
     })->and($classController->getName = $className = 'bar')->and($classController->getFileName = $classFile = 'foo/bar.php')->and($classController->getTraits = array())->and($classController->getStartLine = 1)->and($classController->getEndLine = 12)->and($class = new \mock\reflectionClass(uniqid(), $classController))->and($methodController = new mock\controller())->and($methodController->__construct = function () {
     })->and($methodController->getName = $methodName = 'baz')->and($methodController->isAbstract = false)->and($methodController->getFileName = $classFile)->and($methodController->getDeclaringClass = $class)->and($methodController->getStartLine = 4)->and($methodController->getEndLine = 8)->and($classController->getMethods = array(new \mock\reflectionMethod($className, $methodName, $methodController)))->and($coverage->getMockController()->getClasses = array($className => $classFile, 'foo' => 'bar/foo.php'))->and($xdebugData = array($classFile => array(3 => 1, 4 => 1, 5 => 1, 6 => 0, 7 => 1, 8 => 1, 9 => 1)))->and($filepath = join(DIRECTORY_SEPARATOR, array(__DIR__, 'clover', 'resources', '2.xml')))->and($coverage->setReflectionClassFactory(function () use($class) {
         return $class;
     }))->and($coverage->addXdebugDataForTest($this, $xdebugData))->then->object($report->handleEvent(atoum\runner::runStop, $observable))->isIdenticalTo($report)->castToString($report)->isEqualToContentsOfFile($filepath);
 }
示例#3
0
Use it to configure atoum or anything that needs to be done before EACH run.

More information on documentation:
[en] http://docs.atoum.org/en/chapter3.html#Configuration-files
[fr] http://docs.atoum.org/fr/chapter3.html#Fichier-de-configuration
*/
use mageekguy\atoum;
$report = $script->addDefaultReport();
// This will add the atoum logo before each run.
//$report->addField(new atoum\report\fields\runner\atoum\logo());
// This will add a green or red logo after each run depending on its status.
$report->addField(new atoum\report\fields\runner\result\logo());
// Please replace in next line "Project Name" by your project name and "/path/to/destination/directory" by your destination directory path for html files.
if (!is_dir(__DIR__ . '/coverage')) {
    mkdir(__DIR__ . '/coverage');
}
/*
 * Html coverage
 */
$html = new atoum\report\fields\runner\coverage\html('DbUser', __DIR__ . '/coverage');
$report->addField($html);
/*
 * Clover coverage
 */
$cloverWriter = new \mageekguy\atoum\writers\file(__DIR__ . '/coverage/clover.xml');
$cloverReport = new atoum\reports\asynchronous\clover();
$cloverReport->addWriter($cloverWriter);
$runner->addReport($cloverReport);
// Chargement du fichier bootstrap
$runner->setBootstrapFile(dirname(__FILE__) . '/.bootstrap.atoum.php');
示例#4
0
    mkdir($tests_dir . 'code-coverage');
}
$coverageHtmlField = new atoum\report\fields\runner\coverage\html('Bach Viewer', $coverage_dir);
$coverageHtmlField->setRootUrl('file://' . realpath($coverage_dir));
$xunitWriter = new atoum\writers\file($tests_dir . '/atoum.xunit.xml');
$cloverWriter = new atoum\writers\file($tests_dir . '/clover.xml');
//Not relevant for now
/*$coverageTreemapField = new atoum\report\fields\runner\coverage\treemap(
    'Bach Viewer',
    __DIR__ . '/../treemap'
);
$coverageTreemapField
    ->setTreemapUrl('file://' . realpath(__DIR__ . '/../treemap'))
    ->setHtmlReportBaseUrl($coverageHtmlField->getRootUrl());*/
$xunitReport = new atoum\reports\asynchronous\xunit();
$xunitReport->addWriter($xunitWriter);
$clover = new atoum\reports\asynchronous\clover();
$clover->addWriter($cloverWriter);
$cliReport = $script->addDefaultReport();
/*
This will add the atoum logo before each run
*/
$cliReport->addField(new atoum\report\fields\runner\atoum\logo());
/*
This will add a green or red logo after each run depending on its status
*/
$cliReport->addField(new atoum\report\fields\runner\result\logo());
$runner->addReport($xunitReport);
$runner->addReport($clover);
$runner->addReport($cliReport);
$script->addDefaultReport()->addField($coverageHtmlField);