6 declare(strict_types = 1);
13 use Symfony\Component\Console\Input\ArrayInput;
14 use Symfony\Component\Console\Input\InputArgument;
15 use Symfony\Component\Console\Input\InputInterface;
16 use Symfony\Component\Console\Input\InputOption;
17 use Symfony\Component\Console\Output\OutputInterface;
18 use Symfony\Component\Process\Process;
30 $this->setName(
'run:group')
31 ->setDescription(
'Execute a set of tests referenced via group annotations')
35 InputOption::VALUE_NONE,
36 "only execute a group of tests without generating from source xml" 40 InputOption::VALUE_NONE,
41 'force generation of tests regardless of Magento Instance Configuration' 44 InputArgument::IS_ARRAY | InputArgument::REQUIRED,
45 'group names to be executed via codeception' 63 $skipGeneration = $input->getOption(
'skip-generate');
64 $force = $input->getOption(
'force');
65 $groups = $input->getArgument(
'groups');
66 $remove = $input->getOption(
'remove');
68 if ($skipGeneration and $remove) {
71 "\"skip-generate\" and \"remove\" options can not be used at the same time." 83 if (!$skipGeneration) {
84 $testConfiguration = $this->getGroupAndSuiteConfiguration($groups);
85 $command = $this->getApplication()->find(
'generate:tests');
87 '--tests' => $testConfiguration,
92 $command->run(
new ArrayInput($args),
$output);
95 $codeceptionCommand = realpath(
PROJECT_ROOT .
'/vendor/bin/codecept') .
' run functional --verbose --steps';
97 foreach ($groups as
$group) {
98 $codeceptionCommand .=
" -g {$group}";
101 $process =
new Process($codeceptionCommand);
102 $process->setWorkingDirectory(TESTS_BP);
103 $process->setIdleTimeout(600);
104 $process->setTimeout(0);
119 private function getGroupAndSuiteConfiguration(array $groups)
121 $testConfiguration[
'tests'] = [];
122 $testConfiguration[
'suites'] =
null;
125 foreach ($groups as
$group) {
126 if (array_key_exists(
$group, $availableSuites)) {
127 $testConfiguration[
'suites'][
$group] = [];
130 $testConfiguration[
'tests'] = array_merge(
131 $testConfiguration[
'tests'],
136 $testConfigurationJson = json_encode($testConfiguration);
137 return $testConfigurationJson;
static create($forceGenerate, $phase, $verboseEnabled, $debugEnabled)
execute(InputInterface $input, OutputInterface $output)