Skip to content

Commit 13b7b09

Browse files
authored
Merge branch 'develop' into MQE-1331
2 parents 4f25d64 + fecaf5b commit 13b7b09

File tree

19 files changed

+222
-72
lines changed

19 files changed

+222
-72
lines changed

dev/tests/_bootstrap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
true,
3333
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::UNIT_TEST_PHASE,
3434
true,
35-
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::LEVEL_NONE
35+
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::LEVEL_NONE,
36+
false
3637
);
3738

3839
// Load needed framework env params

dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
1313
use Magento\FunctionalTestingFramework\Util\MagentoTestCase;
1414
use Magento\FunctionalTestingFramework\Util\TestGenerator;
15+
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
1516

1617
class TestGeneratorTest extends MagentoTestCase
1718
{
@@ -38,4 +39,51 @@ public function testEntityException()
3839

3940
$testGeneratorObject->createAllTestFiles(null, []);
4041
}
42+
43+
/**
44+
* Tests that skipped tests do not have a fully generated body
45+
*
46+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
47+
*/
48+
public function testSkippedNoGeneration()
49+
{
50+
$actionInput = 'fakeInput';
51+
$actionObject = new ActionObject('fakeAction', 'comment', [
52+
'userInput' => $actionInput
53+
]);
54+
55+
$annotations = ['skip' => ['issue']];
56+
$testObject = new TestObject("sampleTest", ["merge123" => $actionObject], $annotations, [], "filename");
57+
58+
$testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]);
59+
$output = $testGeneratorObject->assembleTestPhp($testObject);
60+
61+
$this->assertContains('This test is skipped', $output);
62+
$this->assertNotContains($actionInput, $output);
63+
}
64+
65+
/**
66+
* Tests that skipped tests have a fully generated body when --allowSkipped is passed in
67+
*
68+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
69+
*/
70+
public function testAllowSkipped()
71+
{
72+
// Mock allowSkipped for TestGenerator
73+
AspectMock::double(MftfApplicationConfig::class, ['allowSkipped' => true]);
74+
75+
$actionInput = 'fakeInput';
76+
$actionObject = new ActionObject('fakeAction', 'comment', [
77+
'userInput' => $actionInput
78+
]);
79+
80+
$annotations = ['skip' => ['issue']];
81+
$testObject = new TestObject("sampleTest", ["merge123" => $actionObject], $annotations, [], "filename");
82+
83+
$testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]);
84+
$output = $testGeneratorObject->assembleTestPhp($testObject);
85+
86+
$this->assertNotContains('This test is skipped', $output);
87+
$this->assertContains($actionInput, $output);
88+
}
4189
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
*/
19+
class ActionGroupWithParameterizedElementsWithStepKeyReferencesCest
20+
{
21+
/**
22+
* @Features({"TestModule"})
23+
* @Parameter(name = "AcceptanceTester", value="$I")
24+
* @param AcceptanceTester $I
25+
* @return void
26+
* @throws \Exception
27+
*/
28+
public function ActionGroupWithParameterizedElementsWithStepKeyReferences(AcceptanceTester $I)
29+
{
30+
$I->comment("Entering Action Group [actionGroup] actionGroupWithParametrizedSelectors");
31+
$testVariableActionGroup = $I->executeJS("return 1"); // stepKey: testVariableActionGroup
32+
$testVariable2ActionGroup = $I->executeJS("return 'test'"); // stepKey: testVariable2ActionGroup
33+
$I->comment("[createSimpleDataActionGroup] create 'simpleData' entity");
34+
PersistedObjectHandler::getInstance()->createEntity(
35+
"createSimpleDataActionGroup",
36+
"test",
37+
"simpleData",
38+
[],
39+
[]
40+
);
41+
42+
$I->click("#{$testVariable2ActionGroup} .John"); // stepKey: click1ActionGroup
43+
$I->click("#Doe-" . msq("simpleParamData") . "prename .{$testVariableActionGroup}"); // stepKey: click2ActionGroup
44+
$I->seeElement("//div[@name='Tiberius'][@class={$testVariableActionGroup}][@data-element='{$testVariable2ActionGroup}'][" . PersistedObjectHandler::getInstance()->retrieveEntityField('createSimpleData', 'name', 'test') . "]"); // stepKey: see1ActionGroup
45+
$I->comment("Exiting Action Group [actionGroup] actionGroupWithParametrizedSelectors");
46+
}
47+
}

dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,16 @@
9191
</arguments>
9292
<executeJS function="{{section.oneParamElement('full-width')}}" stepKey="keyone"/>
9393
</actionGroup>
94+
<actionGroup name="actionGroupWithParametrizedSelectors">
95+
<arguments>
96+
<argument name="param" type="entity"/>
97+
<argument name="param2" type="entity" defaultValue="simpleParamData"/>
98+
</arguments>
99+
<executeJS function="return 1" stepKey="testVariable"/>
100+
<executeJS function="return 'test'" stepKey="testVariable2"/>
101+
<createData entity="simpleData" stepKey="createSimpleData"/>
102+
<click selector="{{SampleSection.twoParamElement({$testVariable2}, param.firstname)}}" stepKey="click1"/>
103+
<click selector="{{SampleSection.threeParamElement(param.lastname, param2.uniqueNamePre, {$testVariable})}}" stepKey="click2"/>
104+
<seeElement selector="{{SampleSection.fourParamElement(param.middlename, {$testVariable}, {$testVariable2}, $$createSimpleData.name$$)}}" stepKey="see1"/>
105+
</actionGroup>
94106
</actionGroups>

dev/tests/verification/TestModule/Section/SampleSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<element name="oneParamElement" type="button" selector="#element .{{var1}}" parameterized="true"/>
1616
<element name="twoParamElement" type="button" selector="#{{var1}} .{{var2}}" parameterized="true"/>
1717
<element name="threeParamElement" type="button" selector="#{{var1}}-{{var2}} .{{var3}}" parameterized="true"/>
18+
<element name="fourParamElement" type="input" selector="//div[@name='{{arg1}}'][@class={{arg2}}][@data-element='{{arg3}}'][{{arg4}}]" parameterized="true"/>
1819
<element name="threeOneDuplicateParamElement" type="button" selector="#{{var1}}-{{var2}} .{{var1}} [{{var3}}]" parameterized="true"/>
1920
<element name="timeoutElement" type="button" selector="#foo" timeout="30"/>
2021
<element name="mergeElement" type="button" selector="#unMerge"/>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,11 @@
171171
<argument name="section" value="SampleSection"/>
172172
</actionGroup>
173173
</test>
174+
175+
<test name="ActionGroupWithParameterizedElementsWithStepKeyReferences">
176+
<actionGroup ref="actionGroupWithParametrizedSelectors" stepKey="actionGroup">
177+
<argument name="param" value="simpleData"/>
178+
<argument name="param2" value="simpleParamData"/>
179+
</actionGroup>
180+
</test>
174181
</tests>

dev/tests/verification/Tests/ActionGroupGenerationTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,15 @@ public function testActionGroupWithXmlComments()
217217
{
218218
$this->generateAndCompareTest('XmlCommentedActionGroupTest');
219219
}
220+
221+
/**
222+
* Test generation of a test referencing an action group with selectors referencing stepKeys.
223+
*
224+
* @throws \Exception
225+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
226+
*/
227+
public function testActionGroupWithActionStepKeyReferencesInSelectors()
228+
{
229+
$this->generateAndCompareTest('ActionGroupWithParameterizedElementsWithStepKeyReferences');
230+
}
220231
}

docs/commands/mftf.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ vendor/bin/mftf generate:tests [option] [<test name>] [<test name>] [--remove]
122122
| `--force` | Forces test generation, regardless of the module merge order defined in the Magento instance. Example: `generate:tests --force`. |
123123
| `-i,--time` | Set time in minutes to determine the group size when `--config=parallel` is used. The __default value__ is `10`. Example: `generate:tests --config=parallel --time=15`|
124124
| `--tests` | Defines the test configuration as a JSON string.|
125+
| `--allow-skipped` | Allows MFTF to generate and run tests marked with `<skip>.`|
125126
| `--debug or --debug=[<none>]`| Performs schema validations on XML files. <br/> DEFAULT: `generate:tests` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. <br/> DEVELOPER: `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred) when test generation fails because of an invalid XML schema. This option takes extra processing time. Use it after test generation has failed once.</br><br/> NONE: `--debug=none` skips debugging during test generation. Added for backward compatibility, it will be removed in the next MAJOR release.</br>|
126127
| `-r,--remove`| Removes the existing generated suites and tests cleaning up the `_generated` directory before the actual run. For example, `generate:tests SampleTest --remove` cleans up the entire `_generated` directory and generates `SampleTest` only.|
127128

etc/config/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ MODULE_WHITELIST=Magento_Framework,Magento_ConfigurableProductWishlist,Magento_C
4949
#*** Bool property which allows the user to toggle debug output during test execution
5050
#MFTF_DEBUG=
5151

52+
#*** Bool property which allows the user to generate and run tests marked as skipped
53+
#ALLOW_SKIPPED=true
54+
5255
#*** Default timeout for wait actions
5356
#WAIT_TIMEOUT=10
5457
#*** End of .env ***#

etc/config/functional.suite.dist.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ modules:
2828
username: "%MAGENTO_ADMIN_USERNAME%"
2929
password: "%MAGENTO_ADMIN_PASSWORD%"
3030
pageload_timeout: 30
31-
host: %SELENIUM_HOST%
32-
port: %SELENIUM_PORT%
33-
protocol: %SELENIUM_PROTOCOL%
34-
path: %SELENIUM_PATH%
31+
host: "%SELENIUM_HOST%"
32+
port: "%SELENIUM_PORT%"
33+
protocol: "%SELENIUM_PROTOCOL%"
34+
path: "%SELENIUM_PATH%"
3535
capabilities:
3636
chromeOptions:
3737
args: ["--window-size=1280,1024", "--disable-extensions", "--enable-automation", "--disable-gpu", "--enable-Passthrough"]

0 commit comments

Comments
 (0)