diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php index 097d7dfd8..33a29b2e8 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php @@ -46,12 +46,12 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return integer|null|void + * @return integer * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $tests = $input->getArgument('name'); $skipGeneration = $input->getOption('skip-generate'); @@ -85,7 +85,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $process->setWorkingDirectory(TESTS_BP); $process->setIdleTimeout(600); $process->setTimeout(0); - $process->run( + + return $process->run( function ($type, $buffer) use ($output) { $output->write($buffer); } diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php index 13f6b8ade..8257162b9 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php @@ -59,13 +59,13 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return integer|null|void + * @return integer * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { // Create Mftf Configuration MftfApplicationConfig::create( @@ -78,7 +78,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $testConfiguration = $this->getFailedTestList(); if ($testConfiguration === null) { - return null; + // no failed tests found, run is a success + return 0; } $command = $this->getApplication()->find('generate:tests'); @@ -87,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $command->run(new ArrayInput($args), $output); $testManifestList = $this->readTestManifestFile(); - + $returnCode = 0; foreach ($testManifestList as $testCommand) { $codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional '; $codeceptionCommand .= $testCommand; @@ -96,11 +97,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $process->setWorkingDirectory(TESTS_BP); $process->setIdleTimeout(600); $process->setTimeout(0); - $process->run( + $returnCode = max($returnCode, $process->run( function ($type, $buffer) use ($output) { $output->write($buffer); } - ); + )); if (file_exists(self::TESTS_FAILED_FILE)) { $this->failedList = array_merge( $this->failedList, @@ -111,6 +112,8 @@ function ($type, $buffer) use ($output) { foreach ($this->failedList as $test) { $this->writeFailedTestToFile($test, self::TESTS_FAILED_FILE); } + + return $returnCode; } /** diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php index 3098569fb..e895fb66a 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php @@ -53,12 +53,12 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return integer|null|void + * @return integer * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $skipGeneration = $input->getOption('skip-generate'); $force = $input->getOption('force'); @@ -102,7 +102,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $process->setWorkingDirectory(TESTS_BP); $process->setIdleTimeout(600); $process->setTimeout(0); - $process->run( + + return $process->run( function ($type, $buffer) use ($output) { $output->write($buffer); }