diff --git a/dev/tests/_bootstrap.php b/dev/tests/_bootstrap.php index b55f12c2b..4b9d04442 100644 --- a/dev/tests/_bootstrap.php +++ b/dev/tests/_bootstrap.php @@ -82,7 +82,8 @@ $paths = [ $suiteDirectory . DIRECTORY_SEPARATOR . 'functionalSuite.xml', - $suiteDirectory . DIRECTORY_SEPARATOR . 'functionalSuiteHooks.xml' + $suiteDirectory . DIRECTORY_SEPARATOR . 'functionalSuiteHooks.xml', + $suiteDirectory . DIRECTORY_SEPARATOR . 'functionalSuiteExtends.xml' ]; // create and return the iterator for these file paths diff --git a/dev/tests/verification/Resources/ExtendedTestInSuiteChildTestCest.txt b/dev/tests/verification/Resources/ExtendedTestInSuiteChildTestCest.txt new file mode 100644 index 000000000..6658525eb --- /dev/null +++ b/dev/tests/verification/Resources/ExtendedTestInSuiteChildTestCest.txt @@ -0,0 +1,63 @@ +amOnPage("/beforeUrl"); + } + + /** + * @param AcceptanceTester $I + * @throws \Exception + */ + public function _after(AcceptanceTester $I) + { + $I->amOnPage("/afterUrl"); + } + + /** + * @param AcceptanceTester $I + * @throws \Exception + */ + public function _failed(AcceptanceTester $I) + { + $I->saveScreenshot(); + } + + /** + * @Severity(level = SeverityLevel::TRIVIAL) + * @Features({"TestModule"}) + * @Stories({"ExtendedTestInSuiteChildTest"}) + * @Parameter(name = "AcceptanceTester", value="$I") + * @param AcceptanceTester $I + * @return void + * @throws \Exception + */ + public function ExtendedTestInSuiteChildTest(AcceptanceTester $I) + { + $I->comment("Different Input"); + } +} diff --git a/dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml b/dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml index 9d50f7197..345718751 100644 --- a/dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml @@ -158,4 +158,32 @@ + + + + + + <group value="ExtendedTestInSuite"/> + <features value="ExtendedTestInSuite"/> + <stories value="ExtendedTestInSuite"/> + </annotations> + <before> + <amOnPage url="/beforeUrl" stepKey="beforeAmOnPageKey"/> + </before> + <after> + <amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/> + </after> + <comment stepKey="basicCommentWithNoData" userInput="Parent Comment"/> + </test> + + <test name="ExtendedTestInSuiteChildTest" extends="ExtendedTestInSuiteParentTest"> + <annotations> + <severity value="MINOR"/> + <title value="ExtendedTestInSuiteChildTest"/> + <group value="ExtendedTestInSuiteChildTest"/> + <features value="ExtendedTestInSuiteChildTest"/> + <stories value="ExtendedTestInSuiteChildTest"/> + </annotations> + <comment stepKey="basicCommentWithNoData" userInput="Different Input"/> + </test> </tests> \ No newline at end of file diff --git a/dev/tests/verification/Tests/SuiteGenerationTest.php b/dev/tests/verification/Tests/SuiteGenerationTest.php index 52b34b3ef..094a97b5b 100644 --- a/dev/tests/verification/Tests/SuiteGenerationTest.php +++ b/dev/tests/verification/Tests/SuiteGenerationTest.php @@ -285,6 +285,45 @@ public function testSuiteGenerationSingleRun() $this->assertEquals($expectedManifest, file_get_contents(self::getManifestFilePath())); } + /** + * Test extends tests generation in a suite + */ + public function testSuiteGenerationWithExtends() + { + $groupName = 'suiteExtends'; + + $expectedContents = [ + 'ExtendedTestInSuiteChildTestCest.php' + ]; + + // Generate the Suite + SuiteGenerator::getInstance()->generateSuite($groupName); + + // Validate log message and add group name for later deletion + TestLoggingUtil::getInstance()->validateMockLogStatement( + 'info', + "suite generated", + ['suite' => $groupName, 'relative_path' => "_generated" . DIRECTORY_SEPARATOR . $groupName] + ); + self::$TEST_GROUPS[] = $groupName; + + // Validate Yaml file updated + $yml = Yaml::parse(file_get_contents(self::CONFIG_YML_FILE)); + $this->assertArrayHasKey($groupName, $yml['groups']); + + $suiteResultBaseDir = self::GENERATE_RESULT_DIR . + DIRECTORY_SEPARATOR . + $groupName . + DIRECTORY_SEPARATOR; + + // Validate tests have been generated + $dirContents = array_diff(scandir($suiteResultBaseDir), ['..', '.']); + + foreach ($expectedContents as $expectedFile) { + $this->assertTrue(in_array($expectedFile, $dirContents)); + } + } + /** * revert any changes made to config.yml * remove _generated directory diff --git a/dev/tests/verification/_suite/functionalSuiteExtends.xml b/dev/tests/verification/_suite/functionalSuiteExtends.xml new file mode 100644 index 000000000..fccfddcd9 --- /dev/null +++ b/dev/tests/verification/_suite/functionalSuiteExtends.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd"> + <suite name="suiteExtends"> + <include> + <group name="ExtendedTestInSuiteChildTest"/> + </include> + </suite> +</suites> diff --git a/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php b/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php index 19cd025c9..a508d8fd4 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php @@ -110,7 +110,7 @@ public function getTestsByGroup($groupName) foreach ($this->tests as $test) { /** @var TestObject $test */ if (in_array($groupName, $test->getAnnotationByName('group'))) { - $relevantTests[$test->getName()] = $test; + $relevantTests[$test->getName()] = $this->extendTest($test); continue; } }