From dd35d9db2d2750a4aaab3b38791812aed8a7e7b2 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Tue, 20 Aug 2019 15:39:28 -0500 Subject: [PATCH 1/3] MQE-1331: MFTF Run:Test Will Run All Tests That Are Already Generated updated code to run only tests specified in run command --- .../Console/RunTestCommand.php | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php index 76a8bc8f4..1dae2a7d4 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php @@ -8,6 +8,7 @@ namespace Magento\FunctionalTestingFramework\Console; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; +use Magento\FunctionalTestingFramework\Util\TestGenerator; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -88,18 +89,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int $command->run(new ArrayInput($args), $output); } - // we only generate relevant tests here so we can execute "all tests" - $codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . " run functional --verbose --steps"; + $returnCode = 0; + //execute only tests specified as arguments in run command + foreach ($tests as $test) { + $codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional '; + $test = TESTS_MODULE_PATH . + DIRECTORY_SEPARATOR . + TestGenerator::GENERATED_DIR . + DIRECTORY_SEPARATOR . + TestGenerator::DEFAULT_DIR . + DIRECTORY_SEPARATOR . + $test . + 'Cest.php'; + $codeceptionCommand .= $test; + $codeceptionCommand .= ' --verbose --steps'; - $process = new Process($codeceptionCommand); - $process->setWorkingDirectory(TESTS_BP); - $process->setIdleTimeout(600); - $process->setTimeout(0); + $process = new Process($codeceptionCommand); + $process->setWorkingDirectory(TESTS_BP); + $process->setIdleTimeout(600); + $process->setTimeout(0); - return $process->run( - function ($type, $buffer) use ($output) { - $output->write($buffer); - } - ); + $returnCode = max($returnCode, $process->run( + function ($type, $buffer) use ($output) { + $output->write($buffer); + } + )); + } + return $returnCode; } } From d2010f00ac650475d6a3f8f99e308f5752ad794b Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 23 Aug 2019 16:04:01 -0500 Subject: [PATCH 2/3] MQE-1331: MFTF Run:Test Will Run All Tests That Are Already Generated restructured command formation --- .../Console/RunTestCommand.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php index 1dae2a7d4..bf4aa711b 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php @@ -90,21 +90,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $returnCode = 0; + $codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional '; + $testsDirectory = TESTS_MODULE_PATH . DIRECTORY_SEPARATOR . TestGenerator::GENERATED_DIR . DIRECTORY_SEPARATOR; //execute only tests specified as arguments in run command foreach ($tests as $test) { - $codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional '; - $test = TESTS_MODULE_PATH . - DIRECTORY_SEPARATOR . - TestGenerator::GENERATED_DIR . - DIRECTORY_SEPARATOR . - TestGenerator::DEFAULT_DIR . - DIRECTORY_SEPARATOR . - $test . - 'Cest.php'; - $codeceptionCommand .= $test; - $codeceptionCommand .= ' --verbose --steps'; - - $process = new Process($codeceptionCommand); + $testGroup = TestGenerator::DEFAULT_DIR . DIRECTORY_SEPARATOR; + $testName = $test . 'Cest.php'; + $fullCommand = $codeceptionCommand . $testsDirectory . $testGroup . $testName . ' --verbose --steps'; + $process = new Process($fullCommand); $process->setWorkingDirectory(TESTS_BP); $process->setIdleTimeout(600); $process->setTimeout(0); From 4f25d64886fa1b851e7a67333f4ae30b8a7bdd94 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Mon, 26 Aug 2019 09:27:22 -0500 Subject: [PATCH 3/3] MQE-1331: MFTF Run:Test Will Run All Tests That Are Already Generated added error handling --- .../FunctionalTestingFramework/Console/RunTestCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php index bf4aa711b..6d261b6d7 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php @@ -96,6 +96,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($tests as $test) { $testGroup = TestGenerator::DEFAULT_DIR . DIRECTORY_SEPARATOR; $testName = $test . 'Cest.php'; + if (!realpath($testsDirectory . $testGroup . $testName)) { + throw new TestFrameworkException( + $testName . " is not available under " . $testsDirectory . $testGroup + ); + } $fullCommand = $codeceptionCommand . $testsDirectory . $testGroup . $testName . ' --verbose --steps'; $process = new Process($fullCommand); $process->setWorkingDirectory(TESTS_BP);