diff --git a/dev/tests/verification/Resources/ExtendedTestInSuiteChildTestCest.txt b/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt similarity index 84% rename from dev/tests/verification/Resources/ExtendedTestInSuiteChildTestCest.txt rename to dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt index 6658525eb..da343e0e1 100644 --- a/dev/tests/verification/Resources/ExtendedTestInSuiteChildTestCest.txt +++ b/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt @@ -15,10 +15,10 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("[NO TESTCASEID]: ExtendedTestInSuiteChildTest") - * @group ExtendedTestInSuiteChildTest + * @Title("[NO TESTCASEID]: ExtendedChildTestInSuite") + * @group ExtendedTestInSuite */ -class ExtendedTestInSuiteChildTestCest +class ExtendedChildTestInSuiteCest { /** * @param AcceptanceTester $I @@ -50,13 +50,13 @@ class ExtendedTestInSuiteChildTestCest /** * @Severity(level = SeverityLevel::TRIVIAL) * @Features({"TestModule"}) - * @Stories({"ExtendedTestInSuiteChildTest"}) + * @Stories({"ExtendedChildTestInSuite"}) * @Parameter(name = "AcceptanceTester", value="$I") * @param AcceptanceTester $I * @return void * @throws \Exception */ - public function ExtendedTestInSuiteChildTest(AcceptanceTester $I) + public function ExtendedChildTestInSuite(AcceptanceTester $I) { $I->comment("Different Input"); } diff --git a/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt b/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt new file mode 100644 index 000000000..cba6db454 --- /dev/null +++ b/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt @@ -0,0 +1,62 @@ +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({"ExtendedChildTestNotInSuite"}) + * @Parameter(name = "AcceptanceTester", value="$I") + * @param AcceptanceTester $I + * @return void + * @throws \Exception + */ + public function ExtendedChildTestNotInSuite(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 345718751..486a6036f 100644 --- a/dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml @@ -159,13 +159,13 @@ - + - - <group value="ExtendedTestInSuite"/> - <features value="ExtendedTestInSuite"/> - <stories value="ExtendedTestInSuite"/> + <title value="ExtendedTestRelatedToSuiteParentTest"/> + <group value="ExtendedTestRelatedToSuite"/> + <features value="ExtendedTestRelatedToSuiteParentTest"/> + <stories value="ExtendedTestRelatedToSuiteParentTest"/> </annotations> <before> <amOnPage url="/beforeUrl" stepKey="beforeAmOnPageKey"/> @@ -174,16 +174,28 @@ <amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/> </after> <comment stepKey="basicCommentWithNoData" userInput="Parent Comment"/> + <amOnPage url="/url/in/parent" stepKey="amOnPageInParent"/> </test> - <test name="ExtendedTestInSuiteChildTest" extends="ExtendedTestInSuiteParentTest"> + <test name="ExtendedChildTestInSuite" extends="ExtendedTestRelatedToSuiteParentTest"> + <annotations> + <severity value="MINOR"/> + <title value="ExtendedChildTestInSuite"/> + <group value="ExtendedTestInSuite"/> + <features value="ExtendedChildTestInSuite"/> + <stories value="ExtendedChildTestInSuite"/> + </annotations> + <comment stepKey="basicCommentWithNoData" userInput="Different Input"/> + <remove keyForRemoval="amOnPageInParent"/> + </test> + <test name="ExtendedChildTestNotInSuite" extends="ExtendedTestRelatedToSuiteParentTest"> <annotations> <severity value="MINOR"/> - <title value="ExtendedTestInSuiteChildTest"/> - <group value="ExtendedTestInSuiteChildTest"/> - <features value="ExtendedTestInSuiteChildTest"/> - <stories value="ExtendedTestInSuiteChildTest"/> + <title value="ExtendedChildTestNotInSuite"/> + <features value="ExtendedChildTestNotInSuite"/> + <stories value="ExtendedChildTestNotInSuite"/> </annotations> <comment stepKey="basicCommentWithNoData" userInput="Different Input"/> + <remove keyForRemoval="amOnPageInParent"/> </test> </tests> \ No newline at end of file diff --git a/dev/tests/verification/Tests/ExtendedGenerationTest.php b/dev/tests/verification/Tests/ExtendedGenerationTest.php index e7bb0a879..73fb5fdfb 100644 --- a/dev/tests/verification/Tests/ExtendedGenerationTest.php +++ b/dev/tests/verification/Tests/ExtendedGenerationTest.php @@ -118,4 +118,15 @@ public function testExtendingSkippedGeneration() { $this->generateAndCompareTest('ExtendingSkippedTest'); } + + /** + * Tests extending and removing parent steps test generation. + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testExtendingAndRemovingStepsGeneration() + { + $this->generateAndCompareTest('ExtendedChildTestNotInSuite'); + } } diff --git a/dev/tests/verification/Tests/SuiteGenerationTest.php b/dev/tests/verification/Tests/SuiteGenerationTest.php index 094a97b5b..f305e565f 100644 --- a/dev/tests/verification/Tests/SuiteGenerationTest.php +++ b/dev/tests/verification/Tests/SuiteGenerationTest.php @@ -292,8 +292,8 @@ public function testSuiteGenerationWithExtends() { $groupName = 'suiteExtends'; - $expectedContents = [ - 'ExtendedTestInSuiteChildTestCest.php' + $expectedFileNames = [ + 'ExtendedChildTestInSuiteCest' ]; // Generate the Suite @@ -312,15 +312,18 @@ public function testSuiteGenerationWithExtends() $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)); + foreach ($expectedFileNames as $expectedFileName) { + $this->assertTrue(in_array($expectedFileName . ".php", $dirContents)); + $this->assertFileEquals( + self::RESOURCES_PATH . DIRECTORY_SEPARATOR . $expectedFileName . ".txt", + $suiteResultBaseDir . $expectedFileName . ".php" + ); } } diff --git a/dev/tests/verification/_suite/functionalSuiteExtends.xml b/dev/tests/verification/_suite/functionalSuiteExtends.xml index fccfddcd9..aac3b51e5 100644 --- a/dev/tests/verification/_suite/functionalSuiteExtends.xml +++ b/dev/tests/verification/_suite/functionalSuiteExtends.xml @@ -9,7 +9,7 @@ <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"/> + <group name="ExtendedTestInSuite"/> </include> </suite> </suites> diff --git a/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php b/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php index a508d8fd4..1c0f7e2fc 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php @@ -92,10 +92,11 @@ public function getObject($testName) */ public function getAllObjects() { + $testObjects = []; foreach ($this->tests as $testName => $test) { - $this->tests[$testName] = $this->extendTest($test); + $testObjects[$testName] = $this->extendTest($test); } - return $this->tests; + return $testObjects; } /**