public function execute(InputInterface $input, OutputInterface $output) { $output->writeln(\Codeception\Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString()); $options = $input->getOptions(); if ($options['debug']) { $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); } $options['verbosity'] = $output->getVerbosity(); if (!extension_loaded('curl')) { throw new \Exception("Codeception requires CURL extension installed to make tests run\n" . "If you are not sure, how to install CURL, pls refer to StackOverflow\n\n" . "Notice: PHP for Apache/Nginx and CLI can have different php.ini files.\n" . "Please make sure that your PHP you run from console has CURL enabled."); } $config = Configuration::config($options['config']); $suite = $input->getArgument('suite'); $test = $input->getArgument('test'); if (!Configuration::isEmpty() && !$test && strpos($suite, $config['paths']['tests']) === 0) { list($matches, $suite, $test) = $this->matchTestFromFilename($suite, $config['paths']['tests']); } if ($options['group']) { $output->writeln(sprintf("[Groups] <info>%s</info> ", implode(', ', $options['group']))); } if ($input->getArgument('test')) { $options['steps'] = true; } if ($test) { $filter = $this->matchFilteredTestName($test); $options['filter'] = $filter; } $this->codecept = new \Codeception\Codecept((array) $options); if ($suite and $test) { $this->codecept->run($suite, $test); } if (!$test) { $suites = $suite ? explode(',', $suite) : Configuration::suites(); $current_dir = Configuration::projectDir(); $executed = $this->runSuites($suites, $options['skip']); foreach ($config['include'] as $included_config_file) { Configuration::config($full_path = $current_dir . $included_config_file); $namespace = $this->currentNamespace(); $output->writeln("\n<fg=white;bg=magenta>\n[{$namespace}]: tests from {$full_path}\n</fg=white;bg=magenta>"); $suites = $suite ? explode(',', $suite) : Configuration::suites(); $executed += $this->runSuites($suites, $options['skip']); } if (!$executed) { throw new \RuntimeException(sprintf("Suite '%s' could not be found", implode(', ', $suites))); } } $this->codecept->printResult(); if (!$input->getOption('no-exit')) { if ($this->codecept->getResult()->failureCount() or $this->codecept->getResult()->errorCount()) { exit(1); } } }
public function execute(InputInterface $input, OutputInterface $output) { $output->writeln(\Codeception\Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString()); $options = $input->getOptions(); if ($options['debug']) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); } $config = Configuration::config($options['config']); $suite = $input->getArgument('suite'); $test = $input->getArgument('test'); if (!Configuration::isEmpty() && !$test && strpos($suite, $config['paths']['tests']) === 0) { list($matches, $suite, $test) = $this->matchTestFromFilename($suite, $config['paths']['tests']); } if ($options['group']) { $output->writeln(sprintf("[Groups] <info>%s</info> ", implode(', ', $options['group']))); } if ($input->getArgument('test')) { $options['steps'] = true; } $this->codecept = new \Codeception\Codecept((array) $options); if ($suite and $test) { $this->codecept->runSuite($suite, $test); } if (!$test) { $suites = $suite ? explode(',', $suite) : Configuration::suites(); $current_dir = Configuration::projectDir(); $executed = $this->runSuites($suites, $options['skip']); foreach ($config['include'] as $included_config_file) { Configuration::config($full_path = $current_dir . $included_config_file); $namespace = $this->currentNamespace(); $output->writeln("\n<fg=white;bg=magenta>\n[{$namespace}]: tests from {$full_path}\n</fg=white;bg=magenta>"); $suites = $suite ? explode(',', $suite) : Configuration::suites(); $executed += $this->runSuites($suites, $options['skip']); } if (!$executed) { throw new \RuntimeException(sprintf("Suite '%s' could not be found", implode(', ', $suites))); } } $this->codecept->printResult(); if (!$input->getOption('no-exit')) { if ($this->codecept->getResult()->failureCount() or $this->codecept->getResult()->errorCount()) { exit(1); } } }
/** * Executes Run * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @throws \RuntimeException */ public function execute(InputInterface $input, OutputInterface $output) { $this->ensureCurlIsAvailable(); $this->options = $input->getOptions(); $this->output = $output; $config = Configuration::config($this->options['config']); if (!$this->options['colors']) { $this->options['colors'] = $config['settings']['colors']; } if (!$this->options['silent']) { $this->output->writeln(Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString()); } if ($this->options['debug']) { $this->output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); } $userOptions = array_intersect_key($this->options, array_flip($this->passedOptionKeys($input))); $userOptions = array_merge($userOptions, $this->booleanOptions($input, ['xml', 'html', 'json', 'tap', 'coverage', 'coverage-xml', 'coverage-html'])); $userOptions['verbosity'] = $this->output->getVerbosity(); if ($this->options['no-colors']) { $userOptions['colors'] = false; } if ($this->options['group']) { $userOptions['groups'] = $this->options['group']; } if ($this->options['skip-group']) { $userOptions['excludeGroups'] = $this->options['skip-group']; } if ($this->options['report']) { $userOptions['silent'] = true; } if ($this->options['coverage-xml'] or $this->options['coverage-html'] or $this->options['coverage-text']) { $this->options['coverage'] = true; } $suite = $input->getArgument('suite'); $test = $input->getArgument('test'); if (!Configuration::isEmpty() && !$test && strpos($suite, $config['paths']['tests']) === 0) { list($matches, $suite, $test) = $this->matchTestFromFilename($suite, $config['paths']['tests']); } if ($this->options['group']) { $this->output->writeln(sprintf("[Groups] <info>%s</info> ", implode(', ', $this->options['group']))); } if ($input->getArgument('test')) { $this->options['steps'] = true; } if ($test) { $filter = $this->matchFilteredTestName($test); $userOptions['filter'] = $filter; } $this->codecept = new Codecept($userOptions); if ($suite and $test) { $this->codecept->run($suite, $test); } if (!$test) { $suites = $suite ? explode(',', $suite) : Configuration::suites(); $this->executed = $this->runSuites($suites, $this->options['skip']); if (!empty($config['include'])) { $current_dir = Configuration::projectDir(); $suites += $config['include']; $this->runIncludedSuites($config['include'], $current_dir); } if ($this->executed === 0) { throw new \RuntimeException(sprintf("Suite '%s' could not be found", implode(', ', $suites))); } } $this->codecept->printResult(); if (!$input->getOption('no-exit')) { if (!$this->codecept->getResult()->wasSuccessful()) { exit(1); } } }
public function execute(InputInterface $input, OutputInterface $output) { $options = $input->getOptions(); if (!$options['silent']) { $output->writeln(Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString()); } if ($options['no-colors']) { $output->setDecorated(!$options['no-colors']); } if ($options['colors']) { $output->setDecorated($options['colors']); } $options = array_merge($options, $this->booleanOptions($input, ['xml','html','coverage','coverage-xml','coverage-html'])); if ($options['debug']) { $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); } $options['verbosity'] = $output->getVerbosity(); $this->ensureCurlIsAvailable(); $config = Configuration::config($options['config']); $suite = $input->getArgument('suite'); $test = $input->getArgument('test'); if (! Configuration::isEmpty() && ! $test && strpos($suite, $config['paths']['tests']) === 0) { list($matches, $suite, $test) = $this->matchTestFromFilename($suite, $config['paths']['tests']); } if ($options['group']) { $output->writeln(sprintf("[Groups] <info>%s</info> ", implode(', ', $options['group']))); } if ($input->getArgument('test')) { $options['steps'] = true; } if ($test) { $filter = $this->matchFilteredTestName($test); $options['filter'] = $filter; } $this->codecept = new Codecept((array)$options); if ($suite and $test) { $this->codecept->run($suite, $test); } if (! $test) { $suites = $suite ? explode(',', $suite) : Configuration::suites(); $current_dir = Configuration::projectDir(); $executed = $this->runSuites($suites, $options['skip']); foreach ($config['include'] as $included_config_file) { Configuration::config($full_path = $current_dir . $included_config_file); $namespace = $this->currentNamespace(); $output->writeln( "\n<fg=white;bg=magenta>\n[$namespace]: tests from $full_path\n</fg=white;bg=magenta>" ); $suites = $suite ? explode(',', $suite) : Configuration::suites(); $executed += $this->runSuites($suites, $options['skip']); } if (! $executed) { throw new \RuntimeException( sprintf("Suite '%s' could not be found", implode(', ', $suites)) ); } } $this->codecept->printResult(); if (! $input->getOption('no-exit')) { if (! $this->codecept->getResult()->wasSuccessful()) { exit(1); } } }