Skip to content

Commit cce89dd

Browse files
committed
MQE-1151: Extending a skipped test fails to generate the parent before and after actions
- Added parameter to getHooks to return the hooks if the value is true - Added a verification test for the topic
1 parent e95107f commit cce89dd

File tree

5 files changed

+112
-4
lines changed

5 files changed

+112
-4
lines changed
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
7+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
9+
use \Codeception\Util\Locator;
10+
use Yandex\Allure\Adapter\Annotation\Features;
11+
use Yandex\Allure\Adapter\Annotation\Stories;
12+
use Yandex\Allure\Adapter\Annotation\Title;
13+
use Yandex\Allure\Adapter\Annotation\Description;
14+
use Yandex\Allure\Adapter\Annotation\Parameter;
15+
use Yandex\Allure\Adapter\Annotation\Severity;
16+
use Yandex\Allure\Adapter\Model\SeverityLevel;
17+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
18+
19+
/**
20+
* @Title("ChildExtendedTestSkippedParent")
21+
* @group Child
22+
*/
23+
class ExtendingSkippedTestCest
24+
{
25+
/**
26+
* @param AcceptanceTester $I
27+
* @throws \Exception
28+
*/
29+
public function _before(AcceptanceTester $I)
30+
{
31+
$I->amOnPage("/beforeUrl");
32+
}
33+
34+
/**
35+
* @param AcceptanceTester $I
36+
* @throws \Exception
37+
*/
38+
public function _after(AcceptanceTester $I)
39+
{
40+
$I->amOnPage("/afterUrl");
41+
}
42+
43+
/**
44+
* @param AcceptanceTester $I
45+
* @throws \Exception
46+
*/
47+
public function _failed(AcceptanceTester $I)
48+
{
49+
$I->saveScreenshot();
50+
}
51+
52+
/**
53+
* @Severity(level = SeverityLevel::CRITICAL)
54+
* @Features({"TestModule"})
55+
* @Stories({"Child"})
56+
* @Parameter(name = "AcceptanceTester", value="$I")
57+
* @param AcceptanceTester $I
58+
* @return void
59+
* @throws \Exception
60+
*/
61+
public function ExtendingSkippedTest(AcceptanceTester $I)
62+
{
63+
$I->comment("text");
64+
$I->comment("child");
65+
}
66+
}

Diff for: dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml

+30-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
<remove keyForRemoval="beforeAmOnPageKey"/>
117117
</before>
118118
</test>
119-
120119
<test name="ChildExtendedTestNoParent" extends="ThisTestDoesNotExist">
121120
<annotations>
122121
<severity value="CRITICAL"/>
@@ -129,4 +128,34 @@
129128
<remove keyForRemoval="beforeAmOnPageKey"/>
130129
</before>
131130
</test>
131+
<test name="SkippedParent">
132+
<annotations>
133+
<severity value="CRITICAL"/>
134+
<title value="PARENTSKIPPED"/>
135+
<group value="Parent"/>
136+
<features value="Parent"/>
137+
<stories value="Parent"/>
138+
<skip>
139+
<issueId value="NONE"/>
140+
</skip>
141+
</annotations>
142+
<before>
143+
<amOnPage url="/beforeUrl" stepKey="beforeAmOnPageKey"/>
144+
</before>
145+
<after>
146+
<amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/>
147+
</after>
148+
<comment userInput="text" stepKey="keepMe"/>
149+
<comment userInput="text" stepKey="replaceMe"/>
150+
</test>
151+
<test name="ExtendingSkippedTest" extends="SkippedParent">
152+
<annotations>
153+
<severity value="CRITICAL"/>
154+
<title value="ChildExtendedTestSkippedParent"/>
155+
<group value="Child"/>
156+
<features value="Child"/>
157+
<stories value="Child"/>
158+
</annotations>
159+
<comment userInput="child" stepKey="replaceMe"/>
160+
</test>
132161
</tests>

Diff for: dev/tests/verification/Tests/ExtendedGenerationTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,15 @@ public function testExtendedTestGenerationNoParent()
9696
{
9797
$this->generateAndCompareTest('ChildExtendedTestNoParent');
9898
}
99+
100+
/**
101+
* Tests extending a skipped test generation.
102+
*
103+
* @throws \Exception
104+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
105+
*/
106+
public function testExtendingSkippedGeneration()
107+
{
108+
$this->generateAndCompareTest('ExtendingSkippedTest');
109+
}
99110
}

Diff for: src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@ public function getAnnotations()
164164
/**
165165
* Returns hooks.
166166
*
167+
* @param boolean $isExtended
167168
* @return TestHookObject[]
168169
*/
169-
public function getHooks()
170+
public function getHooks($isExtended = false)
170171
{
171172
// if this test is skipped we do not want any before/after actions to generate as the tests will not run
172-
if ($this->isSkipped()) {
173+
if ($this->isSkipped() && !$isExtended) {
173174
return [];
174175
}
175176
return $this->hooks;

Diff for: src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ public function extendActionGroup($actionGroupObject)
146146
private function resolveExtendedHooks($testObject, $parentTestObject)
147147
{
148148
$testHooks = $testObject->getHooks();
149-
$parentHooks = $parentTestObject->getHooks();
149+
// Send true to getHooks to return even if test is skipped
150+
$parentHooks = $parentTestObject->getHooks(true);
150151

151152
// Get the hooks for each Test merge changes from the child hooks to the parent hooks into the child hooks
152153
foreach ($testHooks as $key => $hook) {

0 commit comments

Comments
 (0)