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/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( diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index be9ad9996..bf93fc47a 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -244,6 +244,16 @@ 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())) { + try { + TestObjectHandler::getInstance()->getObject($test->getParentName()); + } catch (TestReferenceException $e) { + print("{$test->getName()} will not be generated. Parent {$e->getMessage()} \n"); + continue; + } + } + $this->debug("Start creating test: " . $test->getCodeceptionName() . ""); $php = $this->assembleTestPhp($test); $cestPhpArray[] = [$test->getCodeceptionName(), $php];