Skip to content

Commit 4522886

Browse files
authored
Merge pull request #279 from magento/MQE-1302
MQE-1302: MFTF Remove Action Not Working For Extended Test
2 parents 85b44c3 + 6c34dab commit 4522886

File tree

7 files changed

+112
-23
lines changed

7 files changed

+112
-23
lines changed

dev/tests/verification/Resources/ExtendedTestInSuiteChildTestCest.txt renamed to dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1515
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1616

1717
/**
18-
* @Title("[NO TESTCASEID]: ExtendedTestInSuiteChildTest")
19-
* @group ExtendedTestInSuiteChildTest
18+
* @Title("[NO TESTCASEID]: ExtendedChildTestInSuite")
19+
* @group ExtendedTestInSuite
2020
*/
21-
class ExtendedTestInSuiteChildTestCest
21+
class ExtendedChildTestInSuiteCest
2222
{
2323
/**
2424
* @param AcceptanceTester $I
@@ -50,13 +50,13 @@ class ExtendedTestInSuiteChildTestCest
5050
/**
5151
* @Severity(level = SeverityLevel::TRIVIAL)
5252
* @Features({"TestModule"})
53-
* @Stories({"ExtendedTestInSuiteChildTest"})
53+
* @Stories({"ExtendedChildTestInSuite"})
5454
* @Parameter(name = "AcceptanceTester", value="$I")
5555
* @param AcceptanceTester $I
5656
* @return void
5757
* @throws \Exception
5858
*/
59-
public function ExtendedTestInSuiteChildTest(AcceptanceTester $I)
59+
public function ExtendedChildTestInSuite(AcceptanceTester $I)
6060
{
6161
$I->comment("Different Input");
6262
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
7+
use \Codeception\Util\Locator;
8+
use Yandex\Allure\Adapter\Annotation\Features;
9+
use Yandex\Allure\Adapter\Annotation\Stories;
10+
use Yandex\Allure\Adapter\Annotation\Title;
11+
use Yandex\Allure\Adapter\Annotation\Description;
12+
use Yandex\Allure\Adapter\Annotation\Parameter;
13+
use Yandex\Allure\Adapter\Annotation\Severity;
14+
use Yandex\Allure\Adapter\Model\SeverityLevel;
15+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
16+
17+
/**
18+
* @Title("[NO TESTCASEID]: ExtendedChildTestNotInSuite")
19+
*/
20+
class ExtendedChildTestNotInSuiteCest
21+
{
22+
/**
23+
* @param AcceptanceTester $I
24+
* @throws \Exception
25+
*/
26+
public function _before(AcceptanceTester $I)
27+
{
28+
$I->amOnPage("/beforeUrl");
29+
}
30+
31+
/**
32+
* @param AcceptanceTester $I
33+
* @throws \Exception
34+
*/
35+
public function _after(AcceptanceTester $I)
36+
{
37+
$I->amOnPage("/afterUrl");
38+
}
39+
40+
/**
41+
* @param AcceptanceTester $I
42+
* @throws \Exception
43+
*/
44+
public function _failed(AcceptanceTester $I)
45+
{
46+
$I->saveScreenshot();
47+
}
48+
49+
/**
50+
* @Severity(level = SeverityLevel::TRIVIAL)
51+
* @Features({"TestModule"})
52+
* @Stories({"ExtendedChildTestNotInSuite"})
53+
* @Parameter(name = "AcceptanceTester", value="$I")
54+
* @param AcceptanceTester $I
55+
* @return void
56+
* @throws \Exception
57+
*/
58+
public function ExtendedChildTestNotInSuite(AcceptanceTester $I)
59+
{
60+
$I->comment("Different Input");
61+
}
62+
}

dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml

+22-10
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@
159159
<comment userInput="child" stepKey="replaceMe"/>
160160
</test>
161161

162-
<test name="ExtendedTestInSuiteParentTest">
162+
<test name="ExtendedTestRelatedToSuiteParentTest">
163163
<annotations>
164164
<severity value="AVERAGE"/>
165-
<title value="ExtendedTestInSuiteParentTest"/>
166-
<group value="ExtendedTestInSuite"/>
167-
<features value="ExtendedTestInSuite"/>
168-
<stories value="ExtendedTestInSuite"/>
165+
<title value="ExtendedTestRelatedToSuiteParentTest"/>
166+
<group value="ExtendedTestRelatedToSuite"/>
167+
<features value="ExtendedTestRelatedToSuiteParentTest"/>
168+
<stories value="ExtendedTestRelatedToSuiteParentTest"/>
169169
</annotations>
170170
<before>
171171
<amOnPage url="/beforeUrl" stepKey="beforeAmOnPageKey"/>
@@ -174,16 +174,28 @@
174174
<amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/>
175175
</after>
176176
<comment stepKey="basicCommentWithNoData" userInput="Parent Comment"/>
177+
<amOnPage url="/url/in/parent" stepKey="amOnPageInParent"/>
177178
</test>
178179

179-
<test name="ExtendedTestInSuiteChildTest" extends="ExtendedTestInSuiteParentTest">
180+
<test name="ExtendedChildTestInSuite" extends="ExtendedTestRelatedToSuiteParentTest">
181+
<annotations>
182+
<severity value="MINOR"/>
183+
<title value="ExtendedChildTestInSuite"/>
184+
<group value="ExtendedTestInSuite"/>
185+
<features value="ExtendedChildTestInSuite"/>
186+
<stories value="ExtendedChildTestInSuite"/>
187+
</annotations>
188+
<comment stepKey="basicCommentWithNoData" userInput="Different Input"/>
189+
<remove keyForRemoval="amOnPageInParent"/>
190+
</test>
191+
<test name="ExtendedChildTestNotInSuite" extends="ExtendedTestRelatedToSuiteParentTest">
180192
<annotations>
181193
<severity value="MINOR"/>
182-
<title value="ExtendedTestInSuiteChildTest"/>
183-
<group value="ExtendedTestInSuiteChildTest"/>
184-
<features value="ExtendedTestInSuiteChildTest"/>
185-
<stories value="ExtendedTestInSuiteChildTest"/>
194+
<title value="ExtendedChildTestNotInSuite"/>
195+
<features value="ExtendedChildTestNotInSuite"/>
196+
<stories value="ExtendedChildTestNotInSuite"/>
186197
</annotations>
187198
<comment stepKey="basicCommentWithNoData" userInput="Different Input"/>
199+
<remove keyForRemoval="amOnPageInParent"/>
188200
</test>
189201
</tests>

dev/tests/verification/Tests/ExtendedGenerationTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,15 @@ public function testExtendingSkippedGeneration()
118118
{
119119
$this->generateAndCompareTest('ExtendingSkippedTest');
120120
}
121+
122+
/**
123+
* Tests extending and removing parent steps test generation.
124+
*
125+
* @throws \Exception
126+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
127+
*/
128+
public function testExtendingAndRemovingStepsGeneration()
129+
{
130+
$this->generateAndCompareTest('ExtendedChildTestNotInSuite');
131+
}
121132
}

dev/tests/verification/Tests/SuiteGenerationTest.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ public function testSuiteGenerationWithExtends()
292292
{
293293
$groupName = 'suiteExtends';
294294

295-
$expectedContents = [
296-
'ExtendedTestInSuiteChildTestCest.php'
295+
$expectedFileNames = [
296+
'ExtendedChildTestInSuiteCest'
297297
];
298298

299299
// Generate the Suite
@@ -312,15 +312,18 @@ public function testSuiteGenerationWithExtends()
312312
$this->assertArrayHasKey($groupName, $yml['groups']);
313313

314314
$suiteResultBaseDir = self::GENERATE_RESULT_DIR .
315-
DIRECTORY_SEPARATOR .
316315
$groupName .
317316
DIRECTORY_SEPARATOR;
318317

319318
// Validate tests have been generated
320319
$dirContents = array_diff(scandir($suiteResultBaseDir), ['..', '.']);
321320

322-
foreach ($expectedContents as $expectedFile) {
323-
$this->assertTrue(in_array($expectedFile, $dirContents));
321+
foreach ($expectedFileNames as $expectedFileName) {
322+
$this->assertTrue(in_array($expectedFileName . ".php", $dirContents));
323+
$this->assertFileEquals(
324+
self::RESOURCES_PATH . DIRECTORY_SEPARATOR . $expectedFileName . ".txt",
325+
$suiteResultBaseDir . $expectedFileName . ".php"
326+
);
324327
}
325328
}
326329

dev/tests/verification/_suite/functionalSuiteExtends.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd">
1010
<suite name="suiteExtends">
1111
<include>
12-
<group name="ExtendedTestInSuiteChildTest"/>
12+
<group name="ExtendedTestInSuite"/>
1313
</include>
1414
</suite>
1515
</suites>

src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ public function getObject($testName)
9292
*/
9393
public function getAllObjects()
9494
{
95+
$testObjects = [];
9596
foreach ($this->tests as $testName => $test) {
96-
$this->tests[$testName] = $this->extendTest($test);
97+
$testObjects[$testName] = $this->extendTest($test);
9798
}
98-
return $this->tests;
99+
return $testObjects;
99100
}
100101

101102
/**

0 commit comments

Comments
 (0)