From d1c1914abe63630751752316de5910ac64fdd582 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Tue, 10 Sep 2019 15:03:54 -0500 Subject: [PATCH 1/4] MQE-1753: Uncaught ArgumentCountError when running bin/mftf static-checks - bug fix --- .../StaticCheck/TestDependencyCheck.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php index a891d42e1..3abbd40c2 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php @@ -88,7 +88,8 @@ public function execute(InputInterface $input) true, MftfApplicationConfig::UNIT_TEST_PHASE, false, - MftfApplicationConfig::LEVEL_NONE + MftfApplicationConfig::LEVEL_NONE, + true ); ModuleResolver::getInstance()->getModulesPath(); From f572a7a0f91d403ff40c1e71ac42e0421dff5975 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 11 Sep 2019 11:47:03 -0500 Subject: [PATCH 2/4] MQE-1754: mftf generate:tests AdminLoginTest -f does not obey the -f flag - set MftfApplicationConfig for generate and run console commands --- .../Config/MftfApplicationConfig.php | 9 +++++-- .../Console/GenerateDocsCommand.php | 3 ++- .../Console/GenerateSuiteCommand.php | 13 ++++++++++ .../Console/GenerateTestsCommand.php | 26 ++++++++----------- .../Console/RunTestCommand.php | 20 ++++++++++++-- .../Console/RunTestFailedCommand.php | 9 ++++--- .../Console/RunTestGroupCommand.php | 8 +++--- 7 files changed, 62 insertions(+), 26 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php b/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php index 6faf322bc..80db27de0 100644 --- a/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php +++ b/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php @@ -115,8 +115,13 @@ private function __construct( * @return void * @throws TestFrameworkException */ - public static function create($forceGenerate, $phase, $verboseEnabled, $debugLevel, $allowSkipped) - { + public static function create( + $forceGenerate = false, + $phase = self::EXECUTION_PHASE, + $verboseEnabled = null, + $debugLevel = self::LEVEL_NONE, + $allowSkipped = false + ) { if (self::$MFTF_APPLICATION_CONTEXT == null) { self::$MFTF_APPLICATION_CONTEXT = new MftfApplicationConfig($forceGenerate, $phase, $verboseEnabled, $debugLevel, $allowSkipped); diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php index 4ed2b6b29..7def3894f 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php @@ -67,7 +67,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $force, MftfApplicationConfig::GENERATION_PHASE, false, - MftfApplicationConfig::LEVEL_NONE + MftfApplicationConfig::LEVEL_NONE, + true ); $allActionGroups = ActionGroupObjectHandler::getInstance()->getAllObjects(); diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php index 815133e4d..7dd3b8cb4 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php @@ -42,7 +42,20 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + $force = $input->getOption('force'); + $debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility $remove = $input->getOption('remove'); + $verbose = $output->isVerbose(); + $allowSkipped = $input->getOption('allowSkipped'); + + // Set application configuration so we can references the user options in our framework + MftfApplicationConfig::create( + $force, + MftfApplicationConfig::GENERATION_PHASE, + $verbose, + $debug, + $allowSkipped + ); // Remove previous GENERATED_DIR if --remove option is used if ($remove) { diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php index c410973c7..6f73e38a1 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php @@ -73,6 +73,15 @@ protected function execute(InputInterface $input, OutputInterface $output) $verbose = $output->isVerbose(); $allowSkipped = $input->getOption('allowSkipped'); + // Set application configuration so we can references the user options in our framework + MftfApplicationConfig::create( + $force, + MftfApplicationConfig::GENERATION_PHASE, + $verbose, + $debug, + $allowSkipped + ); + if (!empty($tests)) { $json = $this->getTestAndSuiteConfiguration($tests); } @@ -93,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ($debug !== MftfApplicationConfig::LEVEL_NONE)); } - $testConfiguration = $this->createTestConfiguration($json, $tests, $force, $debug, $verbose, $allowSkipped); + $testConfiguration = $this->createTestConfiguration($json, $tests); // create our manifest file here $testManifest = TestManifestFactory::makeManifest($config, $testConfiguration['suites']); @@ -126,21 +135,8 @@ protected function execute(InputInterface $input, OutputInterface $output) */ private function createTestConfiguration( $json, - array $tests, - bool $force, - string $debug, - bool $verbose, - bool $allowSkipped + array $tests ) { - // set our application configuration so we can references the user options in our framework - MftfApplicationConfig::create( - $force, - MftfApplicationConfig::GENERATION_PHASE, - $verbose, - $debug, - $allowSkipped - ); - $testConfiguration = []; $testConfiguration['tests'] = $tests; $testConfiguration['suites'] = []; diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php index e1e30589d..b83953dce 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php @@ -32,7 +32,12 @@ protected function configure() 'name', InputArgument::REQUIRED | InputArgument::IS_ARRAY, "name of tests to generate and execute" - )->addOption('skip-generate', 'k', InputOption::VALUE_NONE, "skip generation and execute existing test"); + )->addOption( + 'skip-generate', + 'k', + InputOption::VALUE_NONE, + "skip generation and execute existing test" + ); parent::configure(); } @@ -55,6 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $remove = $input->getOption('remove'); $debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility $allowSkipped = $input->getOption('allowSkipped'); + $verbose = $output->isVerbose(); if ($skipGeneration and $remove) { // "skip-generate" and "remove" options cannot be used at the same time @@ -63,6 +69,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int ); } + // Set application configuration so we can references the user options in our framework + MftfApplicationConfig::create( + $force, + MftfApplicationConfig::EXECUTION_PHASE, + $verbose, + $debug, + $allowSkipped + ); + $testConfiguration = $this->getTestAndSuiteConfiguration($tests); if (!$skipGeneration) { @@ -72,7 +87,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int '--force' => $force, '--remove' => $remove, '--debug' => $debug, - '--allowSkipped' => $allowSkipped + '--allowSkipped' => $allowSkipped, + '-v' => $verbose ]; $command->run(new ArrayInput($args), $output); } diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php index ed00322ff..15ba723e6 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php @@ -71,12 +71,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $force = $input->getOption('force'); $debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility $allowSkipped = $input->getOption('allowSkipped'); + $verbose = $output->isVerbose(); // Create Mftf Configuration MftfApplicationConfig::create( $force, - MftfApplicationConfig::GENERATION_PHASE, - false, + MftfApplicationConfig::EXECUTION_PHASE, + $verbose, $debug, $allowSkipped ); @@ -91,9 +92,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $command = $this->getApplication()->find('generate:tests'); $args = [ '--tests' => $testConfiguration, + '--force' => $force, '--remove' => true, '--debug' => $debug, - '--allowSkipped' => $allowSkipped + '--allowSkipped' => $allowSkipped, + '-v' => $verbose ]; $command->run(new ArrayInput($args), $output); diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php index 81a6b864f..20d290af9 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php @@ -61,6 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $remove = $input->getOption('remove'); $debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility $allowSkipped = $input->getOption('allowSkipped'); + $verbose = $output->isVerbose(); if ($skipGeneration and $remove) { // "skip-generate" and "remove" options cannot be used at the same time @@ -72,8 +73,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Create Mftf Configuration MftfApplicationConfig::create( $force, - MftfApplicationConfig::GENERATION_PHASE, - false, + MftfApplicationConfig::EXECUTION_PHASE, + $verbose, $debug, $allowSkipped ); @@ -86,7 +87,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int '--force' => $force, '--remove' => $remove, '--debug' => $debug, - '--allowSkipped' => $allowSkipped + '--allowSkipped' => $allowSkipped, + '-v' => $verbose ]; $command->run(new ArrayInput($args), $output); From 319001b2e341380dd20df12d503cb09ac6a7aead Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 11 Sep 2019 13:37:44 -0500 Subject: [PATCH 3/4] MQE-1754: mftf generate:tests AdminLoginTest -f does not obey the -f flag - set MftfApplicationConfig for generate and run console commands --- .../Console/GenerateTestsCommand.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php index 6f73e38a1..d70aaaf3a 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php @@ -125,10 +125,6 @@ protected function execute(InputInterface $input, OutputInterface $output) * * @param string $json * @param array $tests - * @param boolean $force - * @param string $debug - * @param boolean $verbose - * @param boolean $allowSkipped * @return array * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException * @throws \Magento\FunctionalTestingFramework\Exceptions\XmlException From 04ff5b55d3f861883fea73842ac3ae869ef8597a Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Fri, 13 Sep 2019 09:41:07 -0500 Subject: [PATCH 4/4] MQE-1754: mftf generate:tests AdminLoginTest -f does not obey the -f flag - set MftfApplicationConfig for generate and run console commands --- .../Console/GenerateTestsCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php index d70aaaf3a..64c7c01d5 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php @@ -123,8 +123,8 @@ protected function execute(InputInterface $input, OutputInterface $output) /** * Function which builds up a configuration including test and suites for consumption of Magento generation methods. * - * @param string $json - * @param array $tests + * @param string $json + * @param array $tests * @return array * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException * @throws \Magento\FunctionalTestingFramework\Exceptions\XmlException