Skip to content

Commit 79cae33

Browse files
committed
Merge branch 'develop' into MQE-683
2 parents af17d02 + 4462b2c commit 79cae33

35 files changed

+552
-106
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Magento Functional Testing Framework Changelog
22
================================================
3+
2.6.3
4+
-----
5+
6+
### New Feature
7+
* `--filter` option was added to `bin/mftf generate:tests` command. For more details please go to https://devdocs.magento.com/mftf/docs/commands/mftf.html#generatetests
38

49
2.6.2
510
-----

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/magento2-functional-testing-framework",
33
"description": "Magento2 Functional Testing Framework",
44
"type": "library",
5-
"version": "2.6.2",
5+
"version": "3.0.0",
66
"license": "AGPL-3.0",
77
"keywords": ["magento", "automation", "functional", "testing"],
88
"config": {

composer.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/functional/tests/MFTF/DevDocs/Test/DeprecatedDevDocsTest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<stories value="[Deprecated] MFTF DevDocs available"/>
1616
<title value="[Deprecated] Magento Functional Testing Framework Documentation is available."/>
1717
<description value="[Deprecated] Magento Functional Testing Framework Documentation is available."/>
18-
<severity value="CRITICAL"/>
18+
<severity value="MINOR"/>
1919
<group value="mftf"/>
2020
</annotations>
2121

dev/tests/unit/Magento/FunctionalTestFramework/Suite/Handlers/SuiteObjectHandlerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testGetSuiteObject()
6565
->withTestActions()
6666
->build();
6767

68-
$mockTestData = ['tests' => array_merge($mockSimpleTest, $mockGroup1Test1, $mockGroup1Test2, $mockGroup2Test1)];
68+
$mockTestData = array_merge($mockSimpleTest, $mockGroup1Test1, $mockGroup1Test2, $mockGroup2Test1);
6969
$this->setMockTestAndSuiteParserOutput($mockTestData, $mockData);
7070

7171
// parse and retrieve suite object with mocked data

dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testGenerateSuite()
6969
->withTestActions()
7070
->build();
7171

72-
$mockTestData = ['tests' => array_merge($mockSimpleTest)];
72+
$mockTestData = array_merge($mockSimpleTest);
7373
$this->setMockTestAndSuiteParserOutput($mockTestData, $mockData);
7474

7575
// parse and generate suite object with mocked data
@@ -105,7 +105,7 @@ public function testGenerateAllSuites()
105105
->withTestActions()
106106
->build();
107107

108-
$mockTestData = ['tests' => array_merge($mockSimpleTest)];
108+
$mockTestData = array_merge($mockSimpleTest);
109109
$this->setMockTestAndSuiteParserOutput($mockTestData, $mockData);
110110

111111
// parse and retrieve suite object with mocked data
@@ -172,7 +172,7 @@ public function testInvalidSuiteTestPair()
172172
->withAnnotations(['group' => [['value' => 'group2']]])
173173
->withTestActions()
174174
->build();
175-
$mockTestData = ['tests' => array_merge($mockSimpleTest, $mockSimpleTest2)];
175+
$mockTestData = array_merge($mockSimpleTest, $mockSimpleTest2);
176176
$this->setMockTestAndSuiteParserOutput($mockTestData, $mockSuiteData);
177177

178178
// Make invalid manifest
@@ -196,7 +196,7 @@ public function testNonExistentSuiteTestPair()
196196
->withAnnotations(['group' => [['value' => 'group1']]])
197197
->withTestActions()
198198
->build();
199-
$mockTestData = ['tests' => array_merge($mockSimpleTest)];
199+
$mockTestData = array_merge($mockSimpleTest);
200200
$this->setMockTestAndSuiteParserOutput($mockTestData, []);
201201

202202
// Make invalid manifest

dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testGetTestObject()
4141

4242
$resolverMock = new MockModuleResolverBuilder();
4343
$resolverMock->setup();
44-
$this->setMockParserOutput(['tests' => $mockData]);
44+
$this->setMockParserOutput($mockData);
4545

4646
// run object handler method
4747
$toh = TestObjectHandler::getInstance();
@@ -135,7 +135,7 @@ public function testGetTestsByGroup()
135135

136136
$resolverMock = new MockModuleResolverBuilder();
137137
$resolverMock->setup();
138-
$this->setMockParserOutput(['tests' => array_merge($includeTest, $excludeTest)]);
138+
$this->setMockParserOutput(array_merge($includeTest, $excludeTest));
139139

140140
// execute test method
141141
$toh = TestObjectHandler::getInstance();
@@ -184,7 +184,7 @@ public function testGetTestWithModuleName()
184184
$resolverMock = new MockModuleResolverBuilder();
185185
$resolverMock->setup(['Vendor_' . $moduleExpected => $filepath]);
186186

187-
$this->setMockParserOutput(['tests' => $mockData]);
187+
$this->setMockParserOutput($mockData);
188188
// Execute Test Method
189189
$toh = TestObjectHandler::getInstance();
190190
$actualTestObject = $toh->getObject($testDataArrayBuilder->testName);
@@ -212,7 +212,7 @@ public function testGetTestObjectWithInvalidExtends()
212212
->build();
213213
$resolverMock = new MockModuleResolverBuilder();
214214
$resolverMock->setup();
215-
$this->setMockParserOutput(['tests' => $testOne]);
215+
$this->setMockParserOutput($testOne);
216216

217217
$toh = TestObjectHandler::getInstance();
218218

@@ -250,7 +250,7 @@ public function testGetAllTestObjectsWithInvalidExtends()
250250

251251
$resolverMock = new MockModuleResolverBuilder();
252252
$resolverMock->setup();
253-
$this->setMockParserOutput(['tests' => array_merge($testOne, $testTwo)]);
253+
$this->setMockParserOutput(array_merge($testOne, $testTwo));
254254

255255
$toh = TestObjectHandler::getInstance();
256256

dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ObjectExtensionUtilTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testGenerateExtendedTest()
6767
->withTestReference("simpleTest")
6868
->build();
6969

70-
$mockTestData = ['tests' => array_merge($mockSimpleTest, $mockExtendedTest)];
70+
$mockTestData = array_merge($mockSimpleTest, $mockExtendedTest);
7171
$this->setMockTestOutput($mockTestData);
7272

7373
// parse and generate test object with mocked data
@@ -112,7 +112,7 @@ public function testGenerateExtendedWithHooks()
112112
->withTestReference("simpleTest")
113113
->build();
114114

115-
$mockTestData = ['tests' => array_merge($mockSimpleTest, $mockExtendedTest)];
115+
$mockTestData = array_merge($mockSimpleTest, $mockExtendedTest);
116116
$this->setMockTestOutput($mockTestData);
117117

118118
// parse and generate test object with mocked data
@@ -143,7 +143,7 @@ public function testExtendedTestNoParent()
143143
->withTestReference("simpleTest")
144144
->build();
145145

146-
$mockTestData = ['tests' => array_merge($mockExtendedTest)];
146+
$mockTestData = array_merge($mockExtendedTest);
147147
$this->setMockTestOutput($mockTestData);
148148

149149
// parse and generate test object with mocked data
@@ -182,7 +182,7 @@ public function testExtendingExtendedTest()
182182
->withTestReference("simpleTest")
183183
->build();
184184

185-
$mockTestData = ['tests' => array_merge($mockParentTest, $mockSimpleTest, $mockExtendedTest)];
185+
$mockTestData = array_merge($mockParentTest, $mockSimpleTest, $mockExtendedTest);
186186
$this->setMockTestOutput($mockTestData);
187187

188188
$this->expectExceptionMessage("Cannot extend a test that already extends another test. Test: simpleTest");

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

-14
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,6 @@ function ($arg) {
146146
'Test' . DIRECTORY_SEPARATOR .'Mftf'
147147
]
148148
);
149-
$mockResolver->verifyInvoked(
150-
'globRelevantPaths',
151-
[
152-
$magentoBaseCodePath
153-
. DIRECTORY_SEPARATOR . "dev"
154-
. DIRECTORY_SEPARATOR . "tests"
155-
. DIRECTORY_SEPARATOR . "acceptance"
156-
. DIRECTORY_SEPARATOR . "tests"
157-
. DIRECTORY_SEPARATOR . "functional"
158-
. DIRECTORY_SEPARATOR . "Magento"
159-
. DIRECTORY_SEPARATOR . "FunctionalTest"
160-
, ''
161-
]
162-
);
163149
}
164150

165151
/**

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

+61
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use AspectMock\Test as AspectMock;
1010

11+
use Magento\FunctionalTestingFramework\Filter\FilterList;
1112
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
1213
use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject;
1314
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
@@ -17,6 +18,16 @@
1718

1819
class TestGeneratorTest extends MagentoTestCase
1920
{
21+
/**
22+
* After method functionality
23+
*
24+
* @return void
25+
*/
26+
public function tearDown()
27+
{
28+
AspectMock::clean();
29+
}
30+
2031
/**
2132
* Basic test to check exceptions for incorrect entities.
2233
*
@@ -99,4 +110,54 @@ public function testAllowSkipped()
99110
$this->assertContains($actionInput, $output);
100111
$this->assertContains($beforeActionInput, $output);
101112
}
113+
114+
/**
115+
* Tests that TestGenerator createAllTestFiles correctly filters based on severity
116+
*
117+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
118+
*/
119+
public function testFilter()
120+
{
121+
// Mock filters for TestGenerator
122+
AspectMock::double(
123+
MftfApplicationConfig::class,
124+
['getFilterList' => new FilterList(['severity' => ["CRITICAL"]])]
125+
);
126+
127+
$actionInput = 'fakeInput';
128+
$actionObject = new ActionObject('fakeAction', 'comment', [
129+
'userInput' => $actionInput
130+
]);
131+
132+
$annotation1 = ['severity' => ['CRITICAL']];
133+
$annotation2 = ['severity' => ['MINOR']];
134+
$test1 = new TestObject(
135+
"test1",
136+
["fakeAction" => $actionObject],
137+
$annotation1,
138+
[],
139+
"filename"
140+
);
141+
$test2 = new TestObject(
142+
"test2",
143+
["fakeAction" => $actionObject],
144+
$annotation2,
145+
[],
146+
"filename"
147+
);
148+
AspectMock::double(TestGenerator::class, ['loadAllTestObjects' => ["sampleTest" => $test1, "test2" => $test2]]);
149+
150+
// Mock createCestFile to return name of tests that testGenerator tried to create
151+
$generatedTests = [];
152+
AspectMock::double(TestGenerator::class, ['createCestFile' => function ($arg1, $arg2) use (&$generatedTests) {
153+
$generatedTests[$arg2] = true;
154+
}]);
155+
156+
$testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $test1, "test2" => $test2]);
157+
$testGeneratorObject->createAllTestFiles(null, []);
158+
159+
// Ensure Test1 was Generated but not Test 2
160+
$this->assertArrayHasKey('test1Cest', $generatedTests);
161+
$this->assertArrayNotHasKey('test2Cest', $generatedTests);
162+
}
102163
}

docs/commands/mftf.md

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ vendor/bin/mftf generate:tests [option] [<test name>] [<test name>] [--remove]
159159
| Option | Description|
160160
| ---| --- |
161161
| `--config=[<default> or <singleRun> or <parallel>]` | Creates a single manifest file with a list of all tests. The default location is `tests/functional/Magento/FunctionalTest/_generated/testManifest.txt`.<br/> You can split the list into multiple groups using `--config=parallel`; the groups will be generated in `_generated/groups/` like `_generated/groups/group1.txt, group2.txt, ...`.<br/> Available values: `default` (default), `singleRun`(same as `default`), and `parallel`.<br/> Example: `generate:tests --config=parallel`. |
162+
| `--filter` | Option to filter tests to be generated.<br/>Template: '<filterName>:<filterValue>'.<br/>Existing filter types: severity.<br/>Existing severity values: BLOCKER, CRITICAL, MAJOR, AVERAGE, MINOR.<br/>Example: --filter=severity:CRITICAL|
162163
| `--force` | Forces test generation, regardless of the module merge order defined in the Magento instance. Example: `generate:tests --force`. |
163164
| `-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`|
164165
| `--tests` | Defines the test configuration as a JSON string.|

docs/data.md

+10
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ The following example shows the usage of `grabValueFrom` in testing, where the r
8585
<fillField selector=".functionalTestSelector" userInput="{$grabStepKey}" stepKey="fillFieldKey1"/>
8686
```
8787

88+
The following is an example of the `Magento/Catalog/Test/Mftf/ActionGroup/AssertDiscountsPercentageOfProductsActionGroup.xml` test:
89+
90+
```xml
91+
<grabValueFrom selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('0')}}" stepKey="grabProductTierPriceInput"/>
92+
<assertEquals stepKey="assertProductTierPriceInput">
93+
<expectedResult type="string">{{amount}}</expectedResult>
94+
<actualResult type="string">$grabProductTierPriceInput</actualResult>
95+
</assertEquals>
96+
```
97+
8898
## Hard-coded data input
8999

90100
The data to operate against can be included as literals in a test. Hard-coded data input can be useful in assertions.

docs/getting-started.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
<div class="bs-callout bs-callout-info" markdown="1">
44
[Find your MFTF version][] of the MFTF.
5-
The latest Magento 2.3.x release supports MFTF 2.4.5.
5+
The latest Magento 2.3.x release supports MFTF 2.5.3.
66
The latest Magento 2.2.x release supports MFTF 2.4.5.
77
</div>
88

9-
## Prepare environment {#prepare-environment}
9+
## Prepare environment {#prepare-environment}
1010

1111
Make sure that you have the following software installed and configured on your development environment:
1212

@@ -53,11 +53,11 @@ Install the Magento application.
5353
composer install
5454
```
5555

56-
## Prepare Magento {#prepare-magento}
56+
## Prepare Magento {#prepare-magento}
5757

5858
Configure the following settings in Magento as described below.
5959

60-
### WYSIWYG settings {#wysiwyg-settings}
60+
### WYSIWYG settings {#wysiwyg-settings}
6161

6262
A Selenium web driver cannot enter data to fields with WYSIWYG.
6363

@@ -74,6 +74,12 @@ or via command line:
7474
bin/magento config:set cms/wysiwyg/enabled disabled
7575
```
7676

77+
Clean the cache after changing the configuration values:
78+
79+
```bash
80+
bin/magento cache:clean config full_page
81+
```
82+
7783
<div class="bs-callout bs-callout-tip">
7884
When you want to test the WYSIWYG functionality, re-enable WYSIWYG in your test suite.
7985
</div>
@@ -97,15 +103,21 @@ bin/magento config:set admin/security/admin_account_sharing 1
97103
bin/magento config:set admin/security/use_form_key 0
98104
```
99105

106+
Clean the cache after changing the configuration values:
107+
108+
```bash
109+
bin/magento cache:clean config full_page
110+
```
111+
100112
### Webserver configuration {#web-server-configuration}
101113

102114
The MFTF does not support executing CLI commands if your web server points to `<MAGE_ROOT_DIR>/pub` directory as recommended in the [Installation Guide][Installation Guide docroot]. For the MFTF to execute the CLI commands, the web server must point to the Magento root directory.
103115

104116
### Nginx settings {#nginx-settings}
105117

106-
If Nginx Web server is used on your development environment then **Use Web Server Rewrites** setting in **Stores** > Settings > **Configuration** > **Web** > **Search Engine Optimization** must be set to **Yes**.
118+
If the Nginx Web server is used on your development environment, then **Use Web Server Rewrites** setting in **Stores** > Settings > **Configuration** > **General** > **Web** > **Search Engine Optimization** must be set to **Yes**.
107119

108-
To be able to run Magento command line commands in tests add the following location block to Nginx configuration file:
120+
To be able to run Magento command line commands in tests, add the following location block to the Nginx configuration file in the Magento root directory:
109121

110122
```conf
111123
location ~* ^/dev/tests/acceptance/utils($|/) {

0 commit comments

Comments
 (0)