From c4099b481191553b2305396f60a8e03553922685 Mon Sep 17 00:00:00 2001 From: Alex Calandra Date: Wed, 1 Aug 2018 15:29:35 -0500 Subject: [PATCH 1/4] MQE-1161: Extended Tests With No Parents Are Skipped - Tests are not generated if they are skipped - Modified verification test to reflect change --- .../verification/Tests/ExtendedGenerationTest.php | 15 +++++++++++++-- .../Util/TestGenerator.php | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/dev/tests/verification/Tests/ExtendedGenerationTest.php b/dev/tests/verification/Tests/ExtendedGenerationTest.php index 46246c45b..e7bb0a879 100644 --- a/dev/tests/verification/Tests/ExtendedGenerationTest.php +++ b/dev/tests/verification/Tests/ExtendedGenerationTest.php @@ -5,6 +5,8 @@ */ namespace tests\verification\Tests; +use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler; +use Magento\FunctionalTestingFramework\Util\TestGenerator; use tests\util\MftfTestCase; class ExtendedGenerationTest extends MftfTestCase @@ -87,14 +89,23 @@ public function testExtendedTestGenerationRemoveHookAction() } /** - * Tests generation of test that attemps to extend a test that doesn't exist + * Tests to ensure extended tests with no parents are not generated * * @throws \Exception * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException */ public function testExtendedTestGenerationNoParent() { - $this->generateAndCompareTest('ChildExtendedTestNoParent'); + $testObject = TestObjectHandler::getInstance()->getObject('ChildExtendedTestNoParent'); + $test = TestGenerator::getInstance(null, [$testObject]); + $test->createAllTestFiles(); + + $cestFile = $test->getExportDir() . + DIRECTORY_SEPARATOR . + $testObject->getCodeceptionName() . + ".php"; + + $this->assertFalse(file_exists($cestFile)); } /** diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index bcae12c9b..5467bef78 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -244,6 +244,13 @@ private function assembleAllTestPhp($testManifest, array $testsToIgnore) $cestPhpArray = []; foreach ($testObjects as $test) { + // Do not generate test if it is an extended test and parent does not exist + if ($test->isSkipped() + && !empty($test->getParentName()) + && !array_key_exists($test->getParentName(), $testObjects)) { + continue; + } + $this->debug("Start creating test: " . $test->getCodeceptionName() . ""); $php = $this->assembleTestPhp($test); $cestPhpArray[] = [$test->getCodeceptionName(), $php]; From 8824d92434d4a87a51855eecbde4328795c19643 Mon Sep 17 00:00:00 2001 From: Alex Calandra Date: Wed, 1 Aug 2018 15:56:19 -0500 Subject: [PATCH 2/4] MQE-1161: Extended Tests With No Parents Are Skipped - Updated skip flagging to use new skip annotation --- .../Test/Util/ObjectExtensionUtil.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php b/src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php index 97f67004a..e67037940 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php @@ -210,10 +210,10 @@ public function skipTest($testObject) $annotations = $testObject->getAnnotations(); // Add skip to the group array if it doesn't already exist - if (array_key_exists('group', $annotations) && !in_array('skip', $annotations['group'])) { - array_push($annotations['group'], 'skip'); - } elseif (!array_key_exists('group', $annotations)) { - $annotations['group'] = ['skip']; + if (array_key_exists('skip', $annotations)) { + return $testObject; + } elseif (!array_key_exists('skip', $annotations)) { + $annotations['skip'] = ['issueId' => "ParentTestDoesNotExist"]; } $skippedTest = new TestObject( From 93fdf78fdbb0afeee9223c28b6e65ef1165d43db Mon Sep 17 00:00:00 2001 From: Alex Calandra Date: Thu, 16 Aug 2018 15:43:12 -0500 Subject: [PATCH 3/4] MQE-1161: Extended Tests With No Parents Are Skipped - Updated conditional to check for parent test existence - Added console information in addition to the log --- .../FunctionalTestingFramework/Util/TestGenerator.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 5467bef78..ade3e41bf 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -245,10 +245,13 @@ private function assembleAllTestPhp($testManifest, array $testsToIgnore) foreach ($testObjects as $test) { // Do not generate test if it is an extended test and parent does not exist - if ($test->isSkipped() - && !empty($test->getParentName()) - && !array_key_exists($test->getParentName(), $testObjects)) { - continue; + if ($test->isSkipped() && !empty($test->getParentName())) { + try { + TestObjectHandler::getInstance()->getObject($test->getParentName()); + } catch (TestReferenceException $e) { + print("{$test->getName()} will be skipped. Parent {$e->getMessage()} \n"); + continue; + } } $this->debug("Start creating test: " . $test->getCodeceptionName() . ""); From a2a0673a1aacaf1574e8b9f72bd02ccc40c8ef75 Mon Sep 17 00:00:00 2001 From: Alex Calandra Date: Mon, 20 Aug 2018 09:35:19 -0500 Subject: [PATCH 4/4] MQE-1161: Extended Tests With No Parents Are Skipped - Updated message to be more explicit --- src/Magento/FunctionalTestingFramework/Util/TestGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index ade3e41bf..d8a5c77f0 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -249,7 +249,7 @@ private function assembleAllTestPhp($testManifest, array $testsToIgnore) try { TestObjectHandler::getInstance()->getObject($test->getParentName()); } catch (TestReferenceException $e) { - print("{$test->getName()} will be skipped. Parent {$e->getMessage()} \n"); + print("{$test->getName()} will not be generated. Parent {$e->getMessage()} \n"); continue; } }