Skip to content

Commit 324bb68

Browse files
committed
MQE-1886: Ability to use grab data between ActionGroups
verification tests + other fixes
1 parent 6a27c3c commit 324bb68

14 files changed

+381
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use \Codeception\Util\Locator;
6+
use Yandex\Allure\Adapter\Annotation\Features;
7+
use Yandex\Allure\Adapter\Annotation\Stories;
8+
use Yandex\Allure\Adapter\Annotation\Title;
9+
use Yandex\Allure\Adapter\Annotation\Description;
10+
use Yandex\Allure\Adapter\Annotation\Parameter;
11+
use Yandex\Allure\Adapter\Annotation\Severity;
12+
use Yandex\Allure\Adapter\Model\SeverityLevel;
13+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
14+
15+
/**
16+
* @Title("[NO TESTCASEID]: Extended ActionGroup Returning Value Test")
17+
* @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest/ExtendedActionGroupReturningValueTest.xml<br>")
18+
*/
19+
class ExtendedActionGroupReturningValueTestCest
20+
{
21+
/**
22+
* @Severity(level = SeverityLevel::CRITICAL)
23+
* @Features({"TestModule"})
24+
* @Parameter(name = "AcceptanceTester", value="$I")
25+
* @param AcceptanceTester $I
26+
* @return void
27+
* @throws \Exception
28+
*/
29+
public function ExtendedActionGroupReturningValueTest(AcceptanceTester $I)
30+
{
31+
$I->comment("Entering Action Group [actionGroupReturningValue] ActionGroupReturningValueActionGroup");
32+
$grabProducts1ActionGroupReturningValue = $I->grabMultiple("selector"); // stepKey: grabProducts1ActionGroupReturningValue
33+
$I->assertCount(99, $grabProducts1ActionGroupReturningValue); // stepKey: assertCountActionGroupReturningValue
34+
$actionGroupReturningValue = $I->return($grabProducts1ActionGroupReturningValue); // stepKey: returnProducts1ActionGroupReturningValue
35+
$I->comment("Exiting Action Group [actionGroupReturningValue] ActionGroupReturningValueActionGroup");
36+
$I->comment("Entering Action Group [actionGroupWithStringUsage1] actionGroupWithStringUsage");
37+
$I->see($actionGroupReturningValue, "#element .{$actionGroupReturningValue}"); // stepKey: see1ActionGroupWithStringUsage1
38+
$I->comment("Exiting Action Group [actionGroupWithStringUsage1] actionGroupWithStringUsage");
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use \Codeception\Util\Locator;
6+
use Yandex\Allure\Adapter\Annotation\Features;
7+
use Yandex\Allure\Adapter\Annotation\Stories;
8+
use Yandex\Allure\Adapter\Annotation\Title;
9+
use Yandex\Allure\Adapter\Annotation\Description;
10+
use Yandex\Allure\Adapter\Annotation\Parameter;
11+
use Yandex\Allure\Adapter\Annotation\Severity;
12+
use Yandex\Allure\Adapter\Model\SeverityLevel;
13+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
14+
15+
/**
16+
* @Title("[NO TESTCASEID]: Extended Child ActionGroup Returning Value Test")
17+
* @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest/ExtendedChildActionGroupReturningValueTest.xml<br>")
18+
*/
19+
class ExtendedChildActionGroupReturningValueTestCest
20+
{
21+
/**
22+
* @Severity(level = SeverityLevel::CRITICAL)
23+
* @Features({"TestModule"})
24+
* @Parameter(name = "AcceptanceTester", value="$I")
25+
* @param AcceptanceTester $I
26+
* @return void
27+
* @throws \Exception
28+
*/
29+
public function ExtendedChildActionGroupReturningValueTest(AcceptanceTester $I)
30+
{
31+
$I->comment("Entering Action Group [extendedActionGroupReturningValue] ExtendedActionGroupReturningValueActionGroup");
32+
$grabProducts1ExtendedActionGroupReturningValue = $I->grabMultiple("selector"); // stepKey: grabProducts1ExtendedActionGroupReturningValue
33+
$I->assertCount(99, $grabProducts1ExtendedActionGroupReturningValue); // stepKey: assertCountExtendedActionGroupReturningValue
34+
$extendedActionGroupReturningValue = $I->return($grabProducts1ExtendedActionGroupReturningValue); // stepKey: returnProducts1ExtendedActionGroupReturningValue
35+
$grabProducts2ExtendedActionGroupReturningValue = $I->grabMultiple("otherSelector"); // stepKey: grabProducts2ExtendedActionGroupReturningValue
36+
$I->assertCount(8000, $grabProducts2ExtendedActionGroupReturningValue); // stepKey: assertSecondCountExtendedActionGroupReturningValue
37+
$extendedActionGroupReturningValue = $I->return($grabProducts2ExtendedActionGroupReturningValue); // stepKey: returnProducts2ExtendedActionGroupReturningValue
38+
$I->comment("Exiting Action Group [extendedActionGroupReturningValue] ExtendedActionGroupReturningValueActionGroup");
39+
$I->comment("Entering Action Group [actionGroupWithStringUsage1] actionGroupWithStringUsage");
40+
$I->see($extendedActionGroupReturningValue, "#element .{$extendedActionGroupReturningValue}"); // stepKey: see1ActionGroupWithStringUsage1
41+
$I->comment("Exiting Action Group [actionGroupWithStringUsage1] actionGroupWithStringUsage");
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use \Codeception\Util\Locator;
6+
use Yandex\Allure\Adapter\Annotation\Features;
7+
use Yandex\Allure\Adapter\Annotation\Stories;
8+
use Yandex\Allure\Adapter\Annotation\Title;
9+
use Yandex\Allure\Adapter\Annotation\Description;
10+
use Yandex\Allure\Adapter\Annotation\Parameter;
11+
use Yandex\Allure\Adapter\Annotation\Severity;
12+
use Yandex\Allure\Adapter\Model\SeverityLevel;
13+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
14+
15+
/**
16+
* @group functional
17+
* @Description("<h3>Test files</h3>verification/TestModule/Test/MergeFunctionalTest/MergedActionGroupReturningValueTest.xml<br>")
18+
*/
19+
class MergedActionGroupReturningValueTestCest
20+
{
21+
/**
22+
* @param AcceptanceTester $I
23+
* @throws \Exception
24+
*/
25+
public function _before(AcceptanceTester $I)
26+
{
27+
$I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam
28+
$I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup");
29+
$I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup
30+
$I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup
31+
$I->comment("Exiting Action Group [beforeGroup] FunctionalActionGroup");
32+
}
33+
34+
/**
35+
* @param AcceptanceTester $I
36+
* @throws \Exception
37+
*/
38+
public function _after(AcceptanceTester $I)
39+
{
40+
$I->comment("Entering Action Group [afterGroup] FunctionalActionGroup");
41+
$I->fillField("#foo", "myData1"); // stepKey: fillField1AfterGroup
42+
$I->fillField("#bar", "myData2"); // stepKey: fillField2AfterGroup
43+
$I->comment("Exiting Action Group [afterGroup] FunctionalActionGroup");
44+
}
45+
46+
/**
47+
* @param AcceptanceTester $I
48+
* @throws \Exception
49+
*/
50+
public function _failed(AcceptanceTester $I)
51+
{
52+
$I->saveScreenshot(); // stepKey: saveScreenshot
53+
}
54+
55+
/**
56+
* @Severity(level = SeverityLevel::CRITICAL)
57+
* @Features({"TestModule"})
58+
* @Stories({"MQE-433"})
59+
* @Parameter(name = "AcceptanceTester", value="$I")
60+
* @param AcceptanceTester $I
61+
* @return void
62+
* @throws \Exception
63+
*/
64+
public function MergedActionGroupReturningValueTest(AcceptanceTester $I)
65+
{
66+
$I->amOnPage("/someUrl"); // stepKey: step1
67+
$I->comment("Entering Action Group [actionGroupWithReturnValue1] MergeActionGroupReturningValueActionGroup");
68+
$I->amOnPage("/Jane/Dane.html"); // stepKey: amOnPage1ActionGroupWithReturnValue1
69+
$I->click(".merge .Jane"); // stepKey: myMergedClickActionGroupWithReturnValue1
70+
$grabMultiple1ActionGroupWithReturnValue1 = $I->grabMultiple("#foo"); // stepKey: grabMultiple1ActionGroupWithReturnValue1
71+
$actionGroupWithReturnValue1 = $I->return($grabMultiple1ActionGroupWithReturnValue1); // stepKey: returnValueActionGroupWithReturnValue1
72+
$I->comment("Exiting Action Group [actionGroupWithReturnValue1] MergeActionGroupReturningValueActionGroup");
73+
$I->comment("Entering Action Group [actionGroupWithStringUsage1] actionGroupWithStringUsage");
74+
$I->see($actionGroupWithReturnValue1, "#element .{$actionGroupWithReturnValue1}"); // stepKey: see1ActionGroupWithStringUsage1
75+
$I->comment("Exiting Action Group [actionGroupWithStringUsage1] actionGroupWithStringUsage");
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="ActionGroupReturningValueActionGroup">
11+
<arguments>
12+
<argument name="count" type="string"/>
13+
</arguments>
14+
<grabMultiple selector="selector" stepKey="grabProducts1"/>
15+
<assertCount stepKey="assertCount">
16+
<expectedResult type="int">{{count}}</expectedResult>
17+
<actualResult type="variable">grabProducts1</actualResult>
18+
</assertCount>
19+
<return value="{$grabProducts1}" stepKey="returnProducts1"/>
20+
</actionGroup>
21+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="ExtendedActionGroupReturningValueActionGroup" extends="ActionGroupReturningValueActionGroup">
11+
<arguments>
12+
<argument name="otherCount" type="string"/>
13+
</arguments>
14+
<grabMultiple selector="otherSelector" stepKey="grabProducts2"/>
15+
<assertCount stepKey="assertSecondCount">
16+
<expectedResult type="int">{{otherCount}}</expectedResult>
17+
<actualResult type="variable">grabProducts2</actualResult>
18+
</assertCount>
19+
<return value="{$grabProducts2}" stepKey="returnProducts2"/>
20+
</actionGroup>
21+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="MergeActionGroupReturningValueActionGroup">
11+
<arguments>
12+
<argument name="myArg"/>
13+
</arguments>
14+
<fillField userInput="Please delete me" selector="#delete" stepKey="deleteMe"/>
15+
<amOnPage url="{{SamplePage.url(myArg.firstname,myArg.lastname)}}" stepKey="amOnPage1"/>
16+
<grabMultiple selector="#foo" stepKey="grabMultiple1"/>
17+
<return value="{$grabMultiple1}" stepKey="returnValue"/>
18+
</actionGroup>
19+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="MergeActionGroupReturningValueActionGroup">
11+
<click stepKey="myMergedClick" selector=".merge .{{myArg.firstname}}" after="amOnPage1"/>
12+
<remove keyForRemoval="deleteMe"/>
13+
</actionGroup>
14+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="ExtendedActionGroupReturningValueTest">
11+
<annotations>
12+
<severity value="CRITICAL"/>
13+
<title value="Extended ActionGroup Returning Value Test"/>
14+
</annotations>
15+
<actionGroup ref="ActionGroupReturningValueActionGroup" stepKey="actionGroupReturningValue">
16+
<argument name="count" value="99"/>
17+
</actionGroup>
18+
<actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroupWithStringUsage1">
19+
<argument name="someArgument" value="{$actionGroupReturningValue}"/>
20+
</actionGroup>
21+
</test>
22+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="ExtendedChildActionGroupReturningValueTest">
11+
<annotations>
12+
<severity value="CRITICAL"/>
13+
<title value="Extended Child ActionGroup Returning Value Test"/>
14+
</annotations>
15+
<actionGroup ref="ExtendedActionGroupReturningValueActionGroup" stepKey="extendedActionGroupReturningValue">
16+
<argument name="count" value="99"/>
17+
<argument name="otherCount" value="8000"/>
18+
</actionGroup>
19+
<actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroupWithStringUsage1">
20+
<argument name="someArgument" value="{$extendedActionGroupReturningValue}"/>
21+
</actionGroup>
22+
</test>
23+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="MergedActionGroupReturningValueTest">
11+
<annotations>
12+
<severity value="CRITICAL"/>
13+
<group value="functional"/>
14+
<features value="Action Group Functional Cest"/>
15+
<stories value="MQE-433"/>
16+
</annotations>
17+
<before>
18+
<createData entity="ReplacementPerson" stepKey="createPersonParam"/>
19+
<actionGroup ref="FunctionalActionGroup" stepKey="beforeGroup"/>
20+
</before>
21+
<amOnPage url="/someUrl" stepKey="step1"/>
22+
<actionGroup ref="MergeActionGroupReturningValueActionGroup" stepKey="actionGroupWithReturnValue1">
23+
<argument name="myArg" value="DefaultPerson"/>
24+
</actionGroup>
25+
<actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroupWithStringUsage1">
26+
<argument name="someArgument" value="{$actionGroupWithReturnValue1}"/>
27+
</actionGroup>
28+
<after>
29+
<actionGroup ref="FunctionalActionGroup" stepKey="afterGroup"/>
30+
</after>
31+
</test>
32+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace tests\verification\Tests;
7+
8+
use tests\util\MftfTestCase;
9+
10+
class ActionGroupWithReturnGenerationTest extends MftfTestCase
11+
{
12+
/**
13+
* Test generation of a test referencing an action group that returns a value.
14+
*
15+
* @throws \Exception
16+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
17+
*/
18+
public function testActionGroupReturningValue()
19+
{
20+
$this->generateAndCompareTest('ActionGroupReturningValueTest');
21+
}
22+
/**
23+
* Test generation of a test referencing a merged action group that returns a value.
24+
*
25+
* @throws \Exception
26+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
27+
*/
28+
public function testMergedActionGroupReturningValue()
29+
{
30+
$this->generateAndCompareTest('MergedActionGroupReturningValueTest');
31+
}
32+
/**
33+
* Test generation of a test referencing an extended action group that returns a value.
34+
*
35+
* @throws \Exception
36+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
37+
*/
38+
public function testExtendedActionGroupReturningValue()
39+
{
40+
$this->generateAndCompareTest('ExtendedActionGroupReturningValueTest');
41+
}
42+
/**
43+
* Test generation of a test referencing an extending child action group that returns a value.
44+
*
45+
* @throws \Exception
46+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
47+
*/
48+
public function testExtendedChildActionGroupReturningValue()
49+
{
50+
$this->generateAndCompareTest('ExtendedChildActionGroupReturningValueTest');
51+
}
52+
}

docs/data.md

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ A test can also reference data that was returned as a result of [test actions][]
7878

7979
Further in the test, the data grabbed by the `someSelector` selector can be referenced using the `stepKey` value. In this case, it is `grabStepKey`.
8080

81+
The `stepKey` value can only be referenced within the test scope that it is defined in (`test`, `before/after`).
82+
8183
The following example shows the usage of `grabValueFrom` in testing, where the returned value is used by action's `stepKey`:
8284

8385
```xml

0 commit comments

Comments
 (0)