Skip to content

Commit b67a169

Browse files
authored
Merge branch 'develop' into MQE-3092
2 parents 19c7859 + 49670c1 commit b67a169

File tree

103 files changed

+2068
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2068
-256
lines changed

.github/.metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"contacts": {
88
"team": {
99
"name": "Magento Quality Engineering / Pangolin",
10-
10+
"DL": "GRP-Pangolin",
1111
"slackChannel": "mftf"
1212
}
1313
},

.github/workflows/main.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ jobs:
3939
- name: Run tests
4040
run: vendor/bin/phpunit --configuration dev/tests/phpunit.xml --testsuite unit --coverage-clover clover.xml
4141

42-
- name: Monitor coverage
43-
if: github.event_name == 'pull_request'
44-
uses: slavcodev/[email protected]
45-
with:
46-
github_token: ${{ secrets.GITHUB_TOKEN }}
47-
clover_file: "clover.xml"
48-
threshold_alert: 10
49-
threshold_warning: 20
42+
# - name: Monitor coverage
43+
# if: github.event_name == 'pull_request'
44+
# uses: slavcodev/[email protected]
45+
# with:
46+
# github_token: ${{ secrets.GITHUB_TOKEN }}
47+
# clover_file: "clover.xml"
48+
# threshold_alert: 10
49+
# threshold_warning: 20
5050

5151
verification-tests:
5252
name: Verification Tests

CHANGELOG.md

+39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
Magento Functional Testing Framework Changelog
22
================================================
3+
3.8.0
4+
---------
5+
6+
### Updates:
7+
* Allow MFTF Helpers to Return Data to MFTF Test
8+
* Improve parallel grouping and fix an issue with unbalanced groups
9+
* Added new action WaitForElementClickable
10+
11+
3.7.3
12+
---------
13+
14+
### Updates:
15+
* Fix encoding issue when secret key contains plus sign
16+
* Adding pagebuilder file upload spinner to loadingMaskLocators
17+
18+
19+
3.7.2
20+
---------
21+
22+
### Bug fix:
23+
* Failed tests weren't logged correctly to `failed` file which caused a failure during run:failed command execution
24+
25+
26+
3.7.1
27+
---------
28+
29+
### GitHub Pull Requests:
30+
* [#873](https://github.com/magento/magento2-functional-testing-framework/pull/873) -- Add check for isBuiltin method (for PHP 8 compatibility) by @karyna-tsymbal-atwix
31+
32+
### Updates
33+
* Moved `hoa/console` to suggest section to avoid issues with PHP8.0
34+
* Update `vlucas/phpdotenv` to the latest versions
35+
* `<seeInCurrentUrl />` encodes special character which caused test failed
36+
* Add filter for groups, now we can generate tests with specific group annotation
37+
* Seprated a `run:failed` command to `generate:failed` and `run:failed`
38+
* `run:failed` command can execute failed tests without need to regenerate failed tests
39+
* Deleting MagentoPwaWebDriver file and moving it to Pwa_tests repo
40+
41+
342
3.7.0
443
---------
544

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": "3.7.0",
5+
"version": "3.8.0",
66
"license": "AGPL-3.0",
77
"keywords": ["magento", "automation", "functional", "testing"],
88
"config": {

composer.lock

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

dev/tests/functional/tests/MFTF/DevDocs/Helper/CustomHelper.php

+11
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,15 @@ public function goTo(
4646
print('$bla = ' . $bla . PHP_EOL);
4747
print('array $arraysomething = [' . implode(', ', $arraysomething) . ']' . PHP_EOL);
4848
}
49+
50+
/**
51+
* Returns value of provided param $text
52+
*
53+
* @param string $text
54+
* @return string
55+
*/
56+
public function getText(string $text): string
57+
{
58+
return $text;
59+
}
4960
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
<argument name="int">987</argument>
4343
</helper>
4444

45+
<helper class="\MFTF\DevDocs\Helper\CustomHelper" method="getText" stepKey="getText">
46+
<argument name="text">some text</argument>
47+
</helper>
48+
<assertEquals stepKey="assertHelperReturnValue" message="Method getText of CustomHelper should return value which may be used as variable in test">
49+
<expectedResult type="string">some text</expectedResult>
50+
<actualResult type="variable">getText</actualResult>
51+
</assertEquals>
52+
4553
<actionGroup ref="HelperActionGroup" stepKey="actionGroupWithCustomHelper">
4654
<argument name="test" value="{{HelperData.entityField}}" />
4755
<argument name="entityTest" value="HelperData" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace tests\unit\Magento\FunctionalTestFramework\Console;
7+
8+
use Magento\FunctionalTestingFramework\Console\GenerateTestFailedCommand;
9+
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
10+
use PHPUnit\Framework\MockObject\MockBuilder;
11+
use PHPUnit\Framework\TestCase;
12+
use Magento\FunctionalTestingFramework\Exceptions\FastFailException;
13+
use Magento\FunctionalTestingFramework\Console\GenerateTestsCommand;
14+
use ReflectionClass;
15+
16+
class GenerateTestFailedCommandTest extends BaseGenerateCommandTest
17+
{
18+
public function testSingleTestNoSuite(): void
19+
{
20+
$testFileReturn = [
21+
"tests/functional/tests/MFTF/_generated/default/SingleTestNoSuiteTest.php:SingleTestNoSuiteTest"
22+
];
23+
$expectedConfiguration = '{"tests":["SingleTestNoSuiteTest"],"suites":null}';
24+
25+
// Create a stub for the SomeClass class.
26+
$stub = $this->getMockBuilder(GenerateTestFailedCommand::class)
27+
->onlyMethods(["readFailedTestFile", "writeFailedTestToFile"])
28+
->getMock();
29+
// Configure the stub.
30+
$stub
31+
->method('readFailedTestFile')
32+
->willReturn($testFileReturn);
33+
$stub
34+
->method('writeFailedTestToFile')
35+
->willReturn(null);
36+
37+
// Run the real code
38+
$configuration = $stub->getFailedTestList("", "");
39+
$this->assertEquals($expectedConfiguration, $configuration);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\Console;
8+
9+
use Magento\FunctionalTestingFramework\Console\RunTestFailedCommand;
10+
11+
class RunTestFailedCommandTest extends BaseGenerateCommandTest
12+
{
13+
/**
14+
* @throws \ReflectionException
15+
*/
16+
public function testMultipleTests(): void
17+
{
18+
$testFailedFile = [
19+
"tests/functional/tests/MFTF/_generated/default/SingleTestNoSuiteTest.php:SingleTestNoSuiteTest",
20+
"tests/functional/tests/MFTF/_generated/SomeSpecificSuite/FirstTestSuiteTest.php:SingleTestSuiteTest",
21+
"tests/functional/tests/MFTF/_generated/SomeSpecificSuite/SecondTestNoSuiteTest.php:SingleTestNoSuiteTest",
22+
"tests/functional/tests/MFTF/_generated/SomeOtherSuite/SecondTestNoSuiteTest.php:SingleTestNoSuiteTest",
23+
];
24+
25+
$expectedResult = [
26+
"tests/functional/tests/MFTF/_generated/default/SingleTestNoSuiteTest.php",
27+
"-g SomeSpecificSuite",
28+
"-g SomeOtherSuite",
29+
];
30+
31+
$runFailed = new RunTestFailedCommand('run:failed');
32+
$filter = $this->invokePrivateMethod($runFailed, 'filterTestsForExecution', [$testFailedFile]);
33+
$this->assertEquals($expectedResult, $filter);
34+
}
35+
36+
/**
37+
* Invoking private method to be able to test it.
38+
* NOTE: Bad practice don't repeat it.
39+
*
40+
* @param $object
41+
* @param $methodName
42+
* @param array $parameters
43+
* @return mixed
44+
* @throws \ReflectionException
45+
*/
46+
private function invokePrivateMethod(&$object, $methodName, array $parameters = [])
47+
{
48+
$reflection = new \ReflectionClass(get_class($object));
49+
$method = $reflection->getMethod($methodName);
50+
$method->setAccessible(true);
51+
return $method->invokeArgs($object, $parameters);
52+
}
53+
}

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

+131-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function testAllowSkipped(): void
162162
* @return void
163163
* @throws TestReferenceException
164164
*/
165-
public function testFilter(): void
165+
public function testSeverityFilter(): void
166166
{
167167
$mockConfig = $this->createMock(MftfApplicationConfig::class);
168168
$fileList = new FilterList(['severity' => ['CRITICAL']]);
@@ -221,6 +221,136 @@ function ($filename) use (&$generatedTests) {
221221
$this->assertArrayNotHasKey('test2Cest', $generatedTests);
222222
}
223223

224+
/**
225+
* Tests that TestGenerator createAllTestFiles correctly filters based on group.
226+
*
227+
* @return void
228+
* @throws TestReferenceException
229+
*/
230+
public function testIncludeGroupFilter(): void
231+
{
232+
$mockConfig = $this->createMock(MftfApplicationConfig::class);
233+
$fileList = new FilterList(['includeGroup' => ['someGroupValue']]);
234+
$mockConfig
235+
->method('getFilterList')
236+
->willReturn($fileList);
237+
238+
$property = new ReflectionProperty(MftfApplicationConfig::class, 'MFTF_APPLICATION_CONTEXT');
239+
$property->setAccessible(true);
240+
$property->setValue($mockConfig);
241+
242+
$actionInput = 'fakeInput';
243+
$actionObject = new ActionObject('fakeAction', 'comment', [
244+
'userInput' => $actionInput
245+
]);
246+
247+
$annotation1 = ['group' => ['someGroupValue']];
248+
$annotation2 = ['group' => ['someOtherGroupValue']];
249+
$test1 = new TestObject(
250+
'test1',
251+
['fakeAction' => $actionObject],
252+
$annotation1,
253+
[],
254+
'filename'
255+
);
256+
$test2 = new TestObject(
257+
'test2',
258+
['fakeAction' => $actionObject],
259+
$annotation2,
260+
[],
261+
'filename'
262+
);
263+
264+
// Mock createCestFile to return name of tests that testGenerator tried to create
265+
$generatedTests = [];
266+
$cestFileCreatorUtil = $this->createMock(CestFileCreatorUtil::class);
267+
$cestFileCreatorUtil
268+
->method('create')
269+
->will(
270+
$this->returnCallback(
271+
function ($filename) use (&$generatedTests) {
272+
$generatedTests[$filename] = true;
273+
}
274+
)
275+
);
276+
277+
$property = new ReflectionProperty(CestFileCreatorUtil::class, 'INSTANCE');
278+
$property->setAccessible(true);
279+
$property->setValue($cestFileCreatorUtil);
280+
281+
$testGeneratorObject = TestGenerator::getInstance('', ['sampleTest' => $test1, 'test2' => $test2]);
282+
$testGeneratorObject->createAllTestFiles();
283+
284+
// Ensure Test1 was Generated but not Test 2
285+
$this->assertArrayHasKey('test1Cest', $generatedTests);
286+
$this->assertArrayNotHasKey('test2Cest', $generatedTests);
287+
}
288+
289+
/**
290+
* Tests that TestGenerator createAllTestFiles correctly filters based on group not included.
291+
*
292+
* @return void
293+
* @throws TestReferenceException
294+
*/
295+
public function testExcludeGroupFilter(): void
296+
{
297+
$mockConfig = $this->createMock(MftfApplicationConfig::class);
298+
$fileList = new FilterList(['excludeGroup' => ['someGroupValue']]);
299+
$mockConfig
300+
->method('getFilterList')
301+
->willReturn($fileList);
302+
303+
$property = new ReflectionProperty(MftfApplicationConfig::class, 'MFTF_APPLICATION_CONTEXT');
304+
$property->setAccessible(true);
305+
$property->setValue($mockConfig);
306+
307+
$actionInput = 'fakeInput';
308+
$actionObject = new ActionObject('fakeAction', 'comment', [
309+
'userInput' => $actionInput
310+
]);
311+
312+
$annotation1 = ['group' => ['someGroupValue']];
313+
$annotation2 = ['group' => ['someOtherGroupValue']];
314+
$test1 = new TestObject(
315+
'test1',
316+
['fakeAction' => $actionObject],
317+
$annotation1,
318+
[],
319+
'filename'
320+
);
321+
$test2 = new TestObject(
322+
'test2',
323+
['fakeAction' => $actionObject],
324+
$annotation2,
325+
[],
326+
'filename'
327+
);
328+
329+
// Mock createCestFile to return name of tests that testGenerator tried to create
330+
$generatedTests = [];
331+
$cestFileCreatorUtil = $this->createMock(CestFileCreatorUtil::class);
332+
$cestFileCreatorUtil
333+
->method('create')
334+
->will(
335+
$this->returnCallback(
336+
function ($filename) use (&$generatedTests) {
337+
$generatedTests[$filename] = true;
338+
}
339+
)
340+
);
341+
342+
$property = new ReflectionProperty(CestFileCreatorUtil::class, 'INSTANCE');
343+
$property->setAccessible(true);
344+
$property->setValue($cestFileCreatorUtil);
345+
346+
$testGeneratorObject = TestGenerator::getInstance('', ['sampleTest' => $test1, 'test2' => $test2]);
347+
$testGeneratorObject->createAllTestFiles();
348+
349+
// Ensure Test2 was Generated but not Test 1
350+
$this->assertArrayNotHasKey('test1Cest', $generatedTests);
351+
$this->assertArrayHasKey('test2Cest', $generatedTests);
352+
}
353+
224354
/**
225355
* @inheritDoc
226356
*/

0 commit comments

Comments
 (0)