Skip to content

Commit 2c8f869

Browse files
committed
MQE-496: Allow passing multiple ActionGroup arguments into parameterized selector
- Add tests for use cases of parametrized selectors with arguments in Action Group - Make tests executable via composer scritpts - Update travis to use composer scripts for testing
1 parent 85372e8 commit 2c8f869

File tree

6 files changed

+253
-2
lines changed

6 files changed

+253
-2
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ php:
44
- 7.1
55
install: composer install --no-interaction --prefer-source
66
script:
7-
- vendor/bin/phpcs ./src --standard=./dev/tests/static/Magento
7+
- composer code-style
8+
- composer tests

composer.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"keywords": ["magento", "automation", "functional", "testing"],
66
"require": {
77
"php": "~7.0",
8-
"codeception/codeception": "2.2|2.3",
8+
"codeception/codeception": "^2.2|^2.3",
99
"flow/jsonpath": ">0.2",
1010
"fzaninotto/faker": "^1.6",
1111
"mustache/mustache": "~2.5"
@@ -20,6 +20,15 @@
2020
"Magento\\FunctionalTestingFramework\\": ["src/Magento/FunctionalTestingFramework"]
2121
}
2222
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"tests\\unit\\": ["dev/tests/unit"]
26+
}
27+
},
28+
"scripts": {
29+
"tests": "vendor/bin/phpunit -c dev/tests/phpunit.xml",
30+
"code-style": "vendor/bin/phpcs ./src --standard=./dev/tests/static/Magento"
31+
},
2332
"extra": {
2433
"hooks": {
2534
"pre-push": "bin/copyright-check"
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_generated\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 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+
* @Severity(level = SeverityLevel::CRITICAL)
19+
* @Title("Title")
20+
* @group functional
21+
* @Features({"Action Group"})
22+
* @Stories({"MQE-496"})
23+
*/
24+
class ActionGroupCest
25+
{
26+
/**
27+
* @Severity(level = SeverityLevel::SEVERE)
28+
* @Title("Action Group With No Argument")
29+
* @Parameter(name = "AcceptanceTester", value="$I")
30+
* @param AcceptanceTester $I
31+
* @return void
32+
*/
33+
public function actionGroupWithNoArguments(AcceptanceTester $I)
34+
{
35+
$I->wait(1);
36+
}
37+
38+
/**
39+
* @Severity(level = SeverityLevel::SEVERE)
40+
* @Title("Action Group With Default Argument Value and Hardcoded Value in Param")
41+
* @Parameter(name = "AcceptanceTester", value="$I")
42+
* @param AcceptanceTester $I
43+
* @return void
44+
*/
45+
public function actionGroupWithDefaultArgumentAndStringSelectorParam(AcceptanceTester $I)
46+
{
47+
$I->see("John", "#element .test1");
48+
}
49+
50+
/**
51+
* @Severity(level = SeverityLevel::SEVERE)
52+
* @Title("Action Group With Passed Argument Value and Hardcoded Value in Param")
53+
* @Parameter(name = "AcceptanceTester", value="$I")
54+
* @param AcceptanceTester $I
55+
* @return void
56+
*/
57+
public function actionGroupWithPassedArgumentAndStringSelectorParam(AcceptanceTester $I)
58+
{
59+
$I->see("John".msq("uniquePerson"), "#element .test1");
60+
}
61+
62+
/**
63+
* @Severity(level = SeverityLevel::SEVERE)
64+
* @Title("Action Group With Default Argument Value and Argument Value in Param")
65+
* @Parameter(name = "AcceptanceTester", value="$I")
66+
* @param AcceptanceTester $I
67+
* @return void
68+
*/
69+
public function actionGroupWithSingleParameterSelectorFromDefaultArgument(AcceptanceTester $I)
70+
{
71+
$I->see("Doe", "#element .John");
72+
}
73+
74+
/**
75+
* @Severity(level = SeverityLevel::SEVERE)
76+
* @Title("Action Group With Passed Argument Value and Argument Value in Param")
77+
* @Parameter(name = "AcceptanceTester", value="$I")
78+
* @param AcceptanceTester $I
79+
* @return void
80+
*/
81+
public function actionGroupWithSingleParameterSelectorFromPassedArgument(AcceptanceTester $I)
82+
{
83+
$I->see("Doe", "#element .John".msq("uniquePerson"));
84+
}
85+
86+
/**
87+
* @Severity(level = SeverityLevel::SEVERE)
88+
* @Title("Action Group With Passed Argument Value and Multiple Argument Values in Param")
89+
* @Parameter(name = "AcceptanceTester", value="$I")
90+
* @param AcceptanceTester $I
91+
* @return void
92+
*/
93+
public function actionGroupWithMultipleParameterSelectorsFromDefaultArgument(AcceptanceTester $I)
94+
{
95+
$I->see("Doe", "#John-Doe .test");
96+
}
97+
98+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
4+
<actionGroup name="actionGroupWithoutArguments">
5+
<wait time="1" mergeKey="waitForNothing" />
6+
</actionGroup>
7+
8+
<actionGroup name="actionGroupWithDefaultArgumentAndStringSelectorParam">
9+
<arguments>
10+
<argument name="someArgument" defaultValue="replacementPerson" />
11+
</arguments>
12+
13+
<see selector="{{SampleSection.oneParamElement('test1')}}" userInput="{{someArgument.firstname}}" mergeKey="seeFirstName" />
14+
</actionGroup>
15+
16+
<actionGroup name="actionGroupWithSingleParameterSelectorFromArgument">
17+
<arguments>
18+
<argument name="someArgument" defaultValue="replacementPerson" />
19+
</arguments>
20+
21+
<see selector="{{SampleSection.oneParamElement(someArgument.firstname)}}" userInput="{{someArgument.lastname}}" mergeKey="seeLastName" />
22+
</actionGroup>
23+
24+
<actionGroup name="actionGroupWithMultipleParameterSelectorsFromArgument">
25+
<arguments>
26+
<argument name="someArgument" defaultValue="replacementPerson" />
27+
</arguments>
28+
29+
<see selector="{{SampleSection.threeParamElement(someArgument.firstname, someArgument.lastname, 'test')}}" userInput="{{someArgument.lastname}}" mergeKey="seeLastName" />
30+
</actionGroup>
31+
</config>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
10+
<cest name="ActionGroupCest">
11+
<annotations>
12+
<severity value="CRITICAL"/>
13+
<title value="Action Group Cest"/>
14+
<group value="functional"/>
15+
<features value="Action Group"/>
16+
<stories value="MQE-496"/>
17+
</annotations>
18+
19+
<test name="actionGroupWithNoArguments">
20+
<annotations>
21+
<severity value="SEVERE"/>
22+
<title value="Action Group With No Argument"/>
23+
</annotations>
24+
25+
<actionGroup ref="actionGroupWithoutArguments" mergeKey="actionGroup" />
26+
</test>
27+
28+
<test name="actionGroupWithDefaultArgumentAndStringSelectorParam">
29+
<annotations>
30+
<severity value="SEVERE"/>
31+
<title value="Action Group With Default Argument Value and Hardcoded Value in Param"/>
32+
</annotations>
33+
34+
<actionGroup ref="actionGroupWithDefaultArgumentAndStringSelectorParam" mergeKey="actionGroup" />
35+
</test>
36+
37+
<test name="actionGroupWithPassedArgumentAndStringSelectorParam">
38+
<annotations>
39+
<severity value="SEVERE"/>
40+
<title value="Action Group With Passed Argument Value and Hardcoded Value in Param"/>
41+
</annotations>
42+
43+
<actionGroup ref="actionGroupWithDefaultArgumentAndStringSelectorParam" mergeKey="actionGroup">
44+
<argument name="someArgument" value="uniquePerson" />
45+
</actionGroup>
46+
</test>
47+
48+
<test name="actionGroupWithSingleParameterSelectorFromDefaultArgument">
49+
<annotations>
50+
<severity value="SEVERE"/>
51+
<title value="Action Group With Default Argument Value and Argument Value in Param"/>
52+
</annotations>
53+
54+
<actionGroup ref="actionGroupWithSingleParameterSelectorFromArgument" mergeKey="actionGroup" />
55+
</test>
56+
57+
<test name="actionGroupWithSingleParameterSelectorFromPassedArgument">
58+
<annotations>
59+
<severity value="SEVERE"/>
60+
<title value="Action Group With Passed Argument Value and Argument Value in Param"/>
61+
</annotations>
62+
63+
<actionGroup ref="actionGroupWithSingleParameterSelectorFromArgument" mergeKey="actionGroup">
64+
<argument name="someArgument" value="uniquePerson" />
65+
</actionGroup>
66+
</test>
67+
68+
<test name="actionGroupWithMultipleParameterSelectorsFromDefaultArgument">
69+
<annotations>
70+
<severity value="SEVERE"/>
71+
<title value="Action Group With Passed Argument Value and Multiple Argument Values in Param"/>
72+
</annotations>
73+
74+
<actionGroup ref="actionGroupWithMultipleParameterSelectorsFromArgument" mergeKey="actionGroup" />
75+
</test>
76+
</cest>
77+
</config>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 Magento\FunctionalTestingFramework\Test\Handlers\CestObjectHandler;
9+
use Magento\FunctionalTestingFramework\Util\TestGenerator;
10+
use PHPUnit\Framework\TestCase;
11+
use tests\verification\Util\FileDiffUtil;
12+
13+
class ActionGroupGenerationTest extends TestCase
14+
{
15+
const ACTION_GROUP_CEST = 'ActionGroupCest';
16+
const RESOURCES_PATH = __DIR__ . '/../Resources';
17+
18+
/**
19+
* Tests flat generation of a hardcoded cest file with no external references.
20+
*/
21+
public function testBasicGeneration()
22+
{
23+
$cest = CestObjectHandler::getInstance()->getObject(self::ACTION_GROUP_CEST);
24+
$test = TestGenerator::getInstance(null, [$cest]);
25+
$test->createAllCestFiles();
26+
27+
$this->assertFileEquals(
28+
self::RESOURCES_PATH . DIRECTORY_SEPARATOR . self::ACTION_GROUP_CEST . ".txt",
29+
$test->getExportDir() .
30+
DIRECTORY_SEPARATOR .
31+
self::ACTION_GROUP_CEST .
32+
".php"
33+
);
34+
}
35+
}

0 commit comments

Comments
 (0)