Best Atoum code snippet using runner.enableBranchesAndPathsCoverage
runner.php
Source:runner.php
...273 {274 $this->runner->disableCodeCoverage();275 return $this;276 }277 public function enableBranchesAndPathsCoverage()278 {279 $this->runner->enableBranchesAndPathsCoverage();280 return $this;281 }282 public function excludeNamespacesFromCoverage(array $namespaces)283 {284 $coverage = $this->runner->getCoverage();285 foreach ($namespaces as $namespace)286 {287 $coverage->excludeNamespace($namespace);288 }289 return $this;290 }291 public function excludeDirectoriesFromCoverage(array $directories)292 {293 $coverage = $this->runner->getCoverage();294 foreach ($directories as $directory)295 {296 $coverage->excludeDirectory($directory);297 }298 return $this;299 }300 public function excludeClassesFromCoverage(array $classes)301 {302 $coverage = $this->runner->getCoverage();303 foreach ($classes as $class)304 {305 $coverage->excludeClass($class);306 }307 return $this;308 }309 public function excludeMethodsFromCoverage(array $methods)310 {311 $coverage = $this->runner->getCoverage();312 foreach ($methods as $method)313 {314 $coverage->excludeMethod($method);315 }316 return $this;317 }318 public function addTest($testPath)319 {320 $this->runner->addTest($testPath);321 return $this;322 }323 public function addTests(array $testPaths)324 {325 foreach ($testPaths as $testPath)326 {327 $this->addTest($testPath);328 }329 return $this;330 }331 public function addTestsFromDirectory($directory)332 {333 $this->runner->addTestsFromDirectory($directory);334 return $this;335 }336 public function addTestsFromDirectories(array $directories)337 {338 foreach ($directories as $directory)339 {340 $this->addTestsFromDirectory($directory);341 }342 return $this;343 }344 public function addTestsFromPattern($pattern)345 {346 $this->runner->addTestsFromPattern($pattern);347 return $this;348 }349 public function addTestsFromPatterns(array $patterns)350 {351 foreach ($patterns as $pattern)352 {353 $this->addTestsFromPattern($pattern);354 }355 return $this;356 }357 public function acceptTestFileExtensions(array $testFileExtensions)358 {359 $this->runner->acceptTestFileExtensions($testFileExtensions);360 return $this;361 }362 public function setBootstrapFile($bootstrapFile)363 {364 $this->runner->setBootstrapFile($bootstrapFile);365 return $this;366 }367 public function setAutoloaderFile($autoloaderFile)368 {369 $this->runner->setAutoloaderFile($autoloaderFile);370 return $this;371 }372 public function enableDebugMode()373 {374 $this->runner->enableDebugMode();375 return $this;376 }377 public function setXdebugConfig($xdebugConfig)378 {379 $this->runner->setXdebugConfig($xdebugConfig);380 return $this;381 }382 public function doNotfailIfVoidMethods()383 {384 $this->runner->doNotfailIfVoidMethods();385 return $this;386 }387 public function failIfVoidMethods()388 {389 $this->runner->failIfVoidMethods();390 return $this;391 }392 public function shouldFailIfVoidMethods()393 {394 return $this->runner->shouldFailIfVoidMethods();395 }396 public function doNotfailIfSkippedMethods()397 {398 $this->runner->doNotfailIfSkippedMethods();399 return $this;400 }401 public function failIfSkippedMethods()402 {403 $this->runner->failIfSkippedMethods();404 return $this;405 }406 public function shouldFailIfSkippedMethods()407 {408 return $this->runner->shouldFailIfSkippedMethods();409 }410 public function init($directory = null)411 {412 $resourceDirectory = static::getResourcesDirectory();413 $currentDirectory = $this->getDirectory();414 if ($directory !== null)415 {416 $currentDirectory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;417 }418 $defaultConfigFile = $currentDirectory . static::defaultConfigFile;419 if ($this->adapter->file_exists($defaultConfigFile) === false || $this->prompt($this->locale->_('Default configuration file \'' . static::defaultConfigFile . '\' already exists in ' . $currentDirectory . ', type \'Y\' to overwrite it...')) === 'Y')420 {421 $this422 ->copy($resourceDirectory . '/configurations/runner/atoum.php.dist', $defaultConfigFile)423 ->writeInfo($this->locale->_('Default configuration file \'' . static::defaultConfigFile . '\' was successfully created in ' . $currentDirectory))424 ;425 }426 $bootstrapFile = $currentDirectory . static::defaultBootstrapFile;427 if ($this->adapter->file_exists($bootstrapFile) == false || $this->prompt($this->locale->_('Default bootstrap file \'' . static::defaultBootstrapFile . '\' already exists in ' . $currentDirectory . ', type \'Y\' to overwrite it...')) === 'Y')428 {429 $this430 ->copy($resourceDirectory . '/configurations/runner/bootstrap.php.dist', $bootstrapFile)431 ->writeInfo($this->locale->_('Default bootstrap file \'' . static::defaultBootstrapFile . '\' was successfully created in ' . $currentDirectory))432 ;433 }434 return $this->stopRun();435 }436 public function setDefaultBootstrapFiles($startDirectory = null)437 {438 foreach (self::getSubDirectoryPath($startDirectory ?: $this->getDirectory()) as $directory)439 {440 $defaultBootstrapFile = $directory . static::defaultBootstrapFile;441 if ($this->adapter->is_file($defaultBootstrapFile) === true)442 {443 $this->setBootstrapFile($defaultBootstrapFile);444 break;445 }446 }447 return $this;448 }449 public function setDefaultAutoloaderFiles($startDirectory = null)450 {451 foreach (self::getSubDirectoryPath($startDirectory ?: $this->getDirectory()) as $directory)452 {453 $defaultAutoloaderFile = $directory . static::defaultAutoloaderFile;454 if ($this->adapter->is_file($defaultAutoloaderFile) === true)455 {456 $this->setAutoloaderFile($defaultAutoloaderFile);457 return $this;458 }459 }460 foreach (self::getSubDirectoryPath($startDirectory ?: $this->getDirectory()) as $directory)461 {462 $composerAutoloaderFile = $directory . static::defaultComposerAutoloaderFile;463 if ($this->adapter->is_file($composerAutoloaderFile) === true)464 {465 $this->setAutoloaderFile($composerAutoloaderFile);466 break;467 }468 }469 return $this;470 }471 public static function autorunMustBeEnabled()472 {473 return (static::$autorunner === true);474 }475 public static function enableAutorun($name)476 {477 static $autorunIsRegistered = false;478 if (static::$autorunner instanceof static)479 {480 throw new exceptions\runtime('Unable to autorun \'' . $name . '\' because \'' . static::$autorunner->getName() . '\' is already set as autorunner');481 }482 if ($autorunIsRegistered === false)483 {484 $autorunner = & static::$autorunner;485 $calledClass = get_called_class();486 register_shutdown_function(function() use (& $autorunner, $calledClass) {487 if ($autorunner instanceof $calledClass)488 {489 set_error_handler(function($error, $message, $file, $line) use ($autorunner) {490 if (error_reporting() !== 0)491 {492 $autorunner->writeError($message . ' in ' . $file . ' at line ' . $line, $error);493 exit(3);494 }495 }496 );497 try498 {499 $score = $autorunner->run()->getRunner()->getScore();500 $isSuccess = $score->getFailNumber() <= 0 && $score->getErrorNumber() <= 0 && $score->getExceptionNumber() <= 0;501 if ($autorunner->shouldFailIfVoidMethods() && $score->getVoidMethodNumber() > 0)502 {503 $isSuccess = false;504 }505 if ($autorunner->shouldFailIfSkippedMethods() && $score->getSkippedMethodNumber() > 0)506 {507 $isSuccess = false;508 }509 exit($isSuccess ? 0 : 1);510 }511 catch (\exception $exception)512 {513 $autorunner->writeError($exception->getMessage());514 exit(2);515 }516 }517 }518 );519 $autorunIsRegistered = true;520 }521 static::$autorunner = new static($name);522 return static::$autorunner;523 }524 public static function disableAutorun()525 {526 static::$autorunner = false;527 }528 protected function setArgumentHandlers()529 {530 parent::setArgumentHandlers()531 ->addArgumentHandler(532 function($script, $argument, $values) {533 if (sizeof($values) !== 0)534 {535 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));536 }537 $script->version();538 },539 array('-v', '--version'),540 null,541 $this->locale->_('Display version')542 )543 ->addArgumentHandler(544 function($script, $argument, $values) {545 if (sizeof($values) !== 0)546 {547 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));548 }549 $script->resetVerbosityLevel();550 $verbosityLevel = substr_count($argument, '+');551 while ($verbosityLevel--)552 {553 $script->increaseVerbosityLevel();554 }555 },556 array('+verbose', '++verbose'),557 null,558 $this->locale->_('Enable verbose mode')559 )560 ->addArgumentHandler(561 function($script, $argument, $values) {562 if (sizeof($values) === 0)563 {564 $values = array(getcwd());565 }566 $script->init(current($values));567 },568 array('--init'),569 '<path/to/directory>',570 $this->locale->_('Create configuration and bootstrap files in <path/to/directory> (Optional, default: %s)', $this->getDirectory())571 )572 ->addArgumentHandler(573 function($script, $argument, $path) {574 if (sizeof($path) != 1)575 {576 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));577 }578 $script->setPhpPath(reset($path));579 },580 array('-p', '--php'),581 '<path/to/php/binary>',582 $this->locale->_('Path to PHP binary which must be used to run tests')583 )584 ->addArgumentHandler(585 function($script, $argument, $defaultReportTitle) {586 if (sizeof($defaultReportTitle) != 1)587 {588 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));589 }590 $script->setDefaultReportTitle(reset($defaultReportTitle));591 },592 array('-drt', '--default-report-title'),593 '<string>',594 $this->locale->_('Define default report title with <string>')595 )596 ->addArgumentHandler(597 function($script, $argument, $file) {598 if (sizeof($file) != 1)599 {600 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));601 }602 $script->setScoreFile(reset($file));603 },604 array('-sf', '--score-file'),605 '<file>',606 $this->locale->_('Save score in file <file>')607 )608 ->addArgumentHandler(609 function($script, $argument, $maxChildrenNumber) {610 if (sizeof($maxChildrenNumber) != 1)611 {612 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));613 }614 $script->setMaxChildrenNumber(reset($maxChildrenNumber));615 },616 array('-mcn', '--max-children-number'),617 '<integer>',618 $this->locale->_('Maximum number of sub-processus which will be run simultaneously')619 )620 ->addArgumentHandler(621 function($script, $argument, $empty) {622 if ($empty)623 {624 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));625 }626 $script->disableCodeCoverage();627 },628 array('-ncc', '--no-code-coverage'),629 null,630 $this->locale->_('Disable code coverage')631 )632 ->addArgumentHandler(633 function($script, $argument, $directories) {634 if (sizeof($directories) <= 0)635 {636 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));637 }638 $script->excludeDirectoriesFromCoverage($directories);639 },640 array('-nccid', '--no-code-coverage-in-directories'),641 '<directory>...',642 $this->locale->_('Disable code coverage in directories <directory>')643 )644 ->addArgumentHandler(645 function($script, $argument, $namespaces) {646 if (sizeof($namespaces) <= 0)647 {648 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));649 }650 $script->excludeNamespacesFromCoverage($namespaces);651 },652 array('-nccfns', '--no-code-coverage-for-namespaces'),653 '<namespace>...',654 $this->locale->_('Disable code coverage for namespaces <namespace>')655 )656 ->addArgumentHandler(657 function($script, $argument, $classes) {658 if (sizeof($classes) <= 0)659 {660 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));661 }662 $script->excludeClassesFromCoverage($classes);663 },664 array('-nccfc', '--no-code-coverage-for-classes'),665 '<class>...',666 $this->locale->_('Disable code coverage for classes <class>')667 )668 ->addArgumentHandler(669 function($script, $argument, $classes) {670 if (sizeof($classes) <= 0)671 {672 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));673 }674 $script->excludeMethodsFromCoverage($classes);675 },676 array('-nccfm', '--no-code-coverage-for-methods'),677 '<method>...',678 $this->locale->_('Disable code coverage for methods <method>')679 )680 ->addArgumentHandler(681 function($script, $argument, $empty) {682 if ($empty)683 {684 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));685 }686 $script->enableBranchesAndPathsCoverage();687 },688 array('-ebpc', '--enable-branch-and-path-coverage'),689 null,690 $this->locale->_('Enable branch and path coverage')691 )692 ->addArgumentHandler(693 function($script, $argument, $files) {694 if (sizeof($files) <= 0)695 {696 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));697 }698 $script->addTests($files);699 },700 array('-f', '--files'),...
.atoum.php
Source:.atoum.php
...10$telemetry->readProjectNameFromComposerJson(__DIR__ . DIRECTORY_SEPARATOR . 'composer.json');11$runner12 ->addExtension(new reports\extension($script))13 ->addReport($coverage)14 ->enableBranchesAndPathsCoverage()15 ->addReport($telemetry)16;17$script18 ->addTestsFromDirectory(__DIR__ . '/tests/units')19 ->addDefaultReport()20;...
enableBranchesAndPathsCoverage
Using AI Code Generation
1$runner = new Runner();2$runner->enableBranchesAndPathsCoverage();3$runner = new Runner();4$runner->enableBranchesAndPathsCoverage();5$runner = new Runner();6$runner->enableBranchesAndPathsCoverage();7$runner = new Runner();8$runner->enableBranchesAndPathsCoverage();9$runner = new Runner();10$runner->enableBranchesAndPathsCoverage();11$runner = new Runner();12$runner->enableBranchesAndPathsCoverage();13$runner = new Runner();14$runner->enableBranchesAndPathsCoverage();15$runner = new Runner();16$runner->enableBranchesAndPathsCoverage();17$runner = new Runner();18$runner->enableBranchesAndPathsCoverage();19$runner = new Runner();20$runner->enableBranchesAndPathsCoverage();21$runner = new Runner();22$runner->enableBranchesAndPathsCoverage();23$runner = new Runner();24$runner->enableBranchesAndPathsCoverage();25$runner = new Runner();26$runner->enableBranchesAndPathsCoverage();
enableBranchesAndPathsCoverage
Using AI Code Generation
1$runner->enableBranchesAndPathsCoverage();2$runner->run();3$runner->disableBranchesAndPathsCoverage();4$runner->run();5$runner->enableBranchesAndPathsCoverage();6$runner->run();7$runner->disableBranchesAndPathsCoverage();8$runner->run();9$runner->enableBranchesAndPathsCoverage();10$runner->run();11$runner->disableBranchesAndPathsCoverage();12$runner->run();13$runner->enableBranchesAndPathsCoverage();14$runner->run();15$runner->disableBranchesAndPathsCoverage();16$runner->run();17$runner->enableBranchesAndPathsCoverage();18$runner->run();19$runner->disableBranchesAndPathsCoverage();20$runner->run();21$runner->enableBranchesAndPathsCoverage();22$runner->run();23$runner->disableBranchesAndPathsCoverage();24$runner->run();25$runner->enableBranchesAndPathsCoverage();26$runner->run();27$runner->disableBranchesAndPathsCoverage();28$runner->run();
enableBranchesAndPathsCoverage
Using AI Code Generation
1require_once 'PHPUnit/TextUI/TestRunner.php';2$runner = new PHPUnit_TextUI_TestRunner();3$runner->enableBranchesAndPathsCoverage();4require_once 'PHPUnit/TextUI/TestRunner.php';5$runner = new PHPUnit_TextUI_TestRunner();6$runner->enableBranchesAndPathsCoverage();7require_once 'PHPUnit/TextUI/TestRunner.php';8$runner = new PHPUnit_TextUI_TestRunner();9$runner->enableBranchesAndPathsCoverage();10require_once 'PHPUnit/TextUI/TestRunner.php';11$runner = new PHPUnit_TextUI_TestRunner();12$runner->enableBranchesAndPathsCoverage();13require_once 'PHPUnit/TextUI/TestRunner.php';14$runner = new PHPUnit_TextUI_TestRunner();15$runner->enableBranchesAndPathsCoverage();16require_once 'PHPUnit/TextUI/TestRunner.php';17$runner = new PHPUnit_TextUI_TestRunner();18$runner->enableBranchesAndPathsCoverage();19require_once 'PHPUnit/TextUI/TestRunner.php';20$runner = new PHPUnit_TextUI_TestRunner();21$runner->enableBranchesAndPathsCoverage();22require_once 'PHPUnit/TextUI/TestRunner.php';23$runner = new PHPUnit_TextUI_TestRunner();24$runner->enableBranchesAndPathsCoverage();25require_once 'PHPUnit/TextUI/TestRunner.php';26$runner = new PHPUnit_TextUI_TestRunner();27$runner->enableBranchesAndPathsCoverage();28require_once 'PHPUnit/TextUI/TestRunner.php';29$runner = new PHPUnit_TextUI_TestRunner();
enableBranchesAndPathsCoverage
Using AI Code Generation
1$runner = new Runner();2$runner->enableBranchesAndPathsCoverage();3$runner->addTestsFromDirectory('tests');4$runner->run();5$test = new Test();6$test->enableBranchesAndPathsCoverage();7$test->run();8$suite = new Suite();9$suite->enableBranchesAndPathsCoverage();10$suite->run();11$testCase = new TestCase();12$testCase->enableBranchesAndPathsCoverage();13$testCase->run();14$result = new TestResult();15$result->enableBranchesAndPathsCoverage();16$result->run();17$coverage = new CodeCoverage();18$coverage->enableBranchesAndPathsCoverage();19$coverage->run();20$report = new CodeCoverageReport();21$report->enableBranchesAndPathsCoverage();22$report->run();23$test = new CodeCoverageReportTest();24$test->enableBranchesAndPathsCoverage();25$test->run();26$test = new CodeCoverageTest();27$test->enableBranchesAndPathsCoverage();28$test->run();29$test = new CodeCoverageUtilTest();30$test->enableBranchesAndPathsCoverage();31$test->run();32$test = new CodeCoverageUtilTest();33$test->enableBranchesAndPathsCoverage();34$test->run();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with enableBranchesAndPathsCoverage on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!