Skip to content

Commit 9b5de03

Browse files
authored
Merge pull request #356 from magento/develop
MFTF 2.4.1 - Merge develop to master
2 parents ef534db + 41caa75 commit 9b5de03

26 files changed

+188
-76
lines changed

.github/CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ All contributors are required to submit a click-through form to agree to the ter
4040

4141
- Unit/integration test coverage
4242
- Proposed documentation update.
43-
For the documentation contribution guidelines, see [DevDocs Contributing][devdocs].
43+
For the documentation contribution guidelines, see [DOCUMENTATION_TEMPLATE][].
4444
7. For large features or changes, [open an issue][issue] to discuss first.
4545
This may prevent duplicate or unnecessary effort, and it may gain you some additional contributors.
4646
8. To report a bug, [open an issue][issue], and follow [guidelines about bugfix issues][issue reporting].
@@ -160,7 +160,7 @@ Label| Description
160160
[create issue]: https://help.github.com/articles/creating-an-issue/
161161
[create pr]: https://help.github.com/articles/creating-a-pull-request/
162162
[Definition of Done]: https://devdocs.magento.com/guides/v2.2/contributor-guide/contributing_dod.html
163-
[devdocs]: https://github.com/magento/devdocs/blob/master/.github/CONTRIBUTING.html
163+
[DOCUMENTATION_TEMPLATE]: https://github.com/magento/devdocs/blob/master/.github/DOCUMENTATION_TEMPLATE.md
164164
[existing issues]: https://github.com/magento/magento2-functional-testing-framework/issues?q=is%3Aopen+is%3Aissue
165165
[existing PRs]: https://github.com/magento/magento2-functional-testing-framework/pulls?q=is%3Aopen+is%3Apr
166166
[GitHub documentation]: https://help.github.com/articles/syncing-a-fork
@@ -171,4 +171,4 @@ Label| Description
171171
[Magento Contributor Agreement]: http://www.magento.com/legaldocuments/mca
172172
[MFTF repository]: https://github.com/magento/magento2-functional-testing-framework
173173
[open new issue]: https://github.com/magento/magento2-functional-testing-framework/issues/new
174-
[Travis CI]: https://travis-ci.com/magento/magento2-functional-testing-framework/pull_requests
174+
[Travis CI]: https://travis-ci.com/magento/magento2-functional-testing-framework/pull_requests

.github/DOCUMENTATION_TEMPLATE.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# How to contribute to MFTF docs
2+
3+
We welcome contributions to the MFTF documentation, which is kept within the `docs/` folder in this repository.
4+
This page describes the submitting process and serves as a template for a properly written content.
5+
The contribution workflow is the same as submitting code.
6+
7+
1. Create a branch from the `develop` branch in the [MFTF repository][].
8+
1. Make edits/additions/deletions as needed. Read the [Basic Template][] for tips on how to write with Markdown.
9+
1. Submit your pull request to the `develop` branch.
10+
11+
Once submitted, a member of the documentation team will review and merge it.
12+
We will inform you if it needs any additional processing.
13+
14+
The documentation in this repository is used as the source for the [MFTF documentation][].
15+
Any changes to the table of contents will need to be made through a separate pull request in the regular [Magento Developer documentation repository][].
16+
17+
Read more about how to [Contribute to Magento Devdocs][].
18+
19+
<!-- For readability, we abstract the link URLS to the bottom of the page. The extra set of square brackets denotes it is a link, rather than plain brackets. >
20+
21+
<!-- Link Definitions -->
22+
[Magento Developer documentation repository]: https://github.com/magento/devdocs/blob/master/_data/toc/mftf.yml
23+
[MFTF repository]: https://github.com/magento/magento2-functional-testing-framework
24+
[Contribute to Magento Devdocs]: https://github.com/magento/devdocs/blob/master/.github/CONTRIBUTING.md
25+
[MFTF documentation]: https://devdocs.magento.com/mftf/docs/introduction.html
26+
[Basic Template]: https://devdocs.magento.com/guides/v2.3/contributor-guide/templates/basic_template.html

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Magento Functional Testing Framework Changelog
22
================================================
33

4+
2.4.1
5+
-----
6+
* Traceability
7+
* XSD Schema validation is now enabled by default in `generate:tests`, `run:test`, `run:failed`, `run:group`
8+
* `--debug` option for the above commands has been updated to include different debug levels
9+
* See DevDocs for details
10+
11+
### Fixes
12+
* Fixed an issue where `skipReadiness` attribute would cause false XSD Schema validation errors.
13+
414
2.4.0
515
-----
616
### Enhancements

bin/mftf

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ try {
2929
try {
3030
$application = new Symfony\Component\Console\Application();
3131
$application->setName('Magento Functional Testing Framework CLI');
32-
$application->setVersion('2.4.0');
32+
$application->setVersion('2.4.1');
3333
/** @var \Magento\FunctionalTestingFramework\Console\CommandListInterface $commandList */
3434
$commandList = new \Magento\FunctionalTestingFramework\Console\CommandList;
3535
foreach ($commandList->getCommands() as $command) {

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.4.0",
5+
"version": "2.4.1",
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/_bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
true,
3333
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::UNIT_TEST_PHASE,
3434
true,
35-
false
35+
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::LEVEL_NONE
3636
);
3737

3838
// Load needed framework env params

dev/tests/verification/Resources/BasicFunctionalTest.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ class BasicFunctionalTestCest
6060
{
6161
$I->comment("");
6262
$I->comment("");
63-
$I->skipReadinessCheck(true);
64-
$I->comment("skipReadiness");
65-
$I->skipReadinessCheck(false);
63+
$I->comment("seeComment");
6664
$someVarDefinition = $I->grabValueFrom();
6765
$I->acceptPopup();
6866
$I->amOnPage("/test/url");

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

-4
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@
115115
<see selector=".selector" userInput="{{sameStepKeyAsArg}}" stepKey="arg1" />
116116
</actionGroup>
117117

118-
<actionGroup name="actionGroupWithSkipReadinessActions">
119-
<comment userInput="ActionGroupSkipReadiness" stepKey="skip" skipReadiness="true"/>
120-
</actionGroup>
121-
122118
<actionGroup name="actionGroupWithSectionAndData">
123119
<arguments>
124120
<argument name="content" type="string"/>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</after>
2525
<comment stepKey="basicCommentWithNoData" userInput="{{emptyData.noData}}"/>
2626
<comment stepKey="basicCommentWithDefinitelyNoData" userInput="{{emptyData.definitelyNoData}}"/>
27-
<comment stepKey="ReadinessCheckSkipped" userInput="skipReadiness" skipReadiness="true"/>
27+
<comment stepKey="basicCommentWithData" userInput="seeComment"/>
2828
<grabValueFrom stepKey="someVarDefinition"/>
2929
<acceptPopup stepKey="acceptPopupKey1"/>
3030
<amOnPage stepKey="amOnPageKey1" url="/test/url"/>

dev/tests/verification/Tests/ActionGroupGenerationTest.php

-11
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,6 @@ public function testActionGroupWithArgContainingStepKey()
185185
$this->generateAndCompareTest('ActionGroupContainsStepKeyInArgText');
186186
}
187187

188-
/**
189-
* Test an action group with an arg containing stepKey text
190-
*
191-
* @throws \Exception
192-
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
193-
*/
194-
public function testActionGroupWithSkipReadiness()
195-
{
196-
$this->generateAndCompareTest('ActionGroupSkipReadiness');
197-
}
198-
199188
/**
200189
* Test an action group with an arg containing stepKey text
201190
*

dev/tests/verification/Tests/SchemaValidationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SchemaValidationTest extends MftfTestCase
1919
*/
2020
public function testInvalidTestSchema()
2121
{
22-
AspectMock::double(MftfApplicationConfig::class, ['debugEnabled' => true]);
22+
AspectMock::double(MftfApplicationConfig::class, ['getDebugLevel' => MftfApplicationConfig::LEVEL_DEVELOPER]);
2323
$testFile = ['testFile.xml' => "<tests><test name='testName'><annotations>a</annotations></test></tests>"];
2424
$expectedError = TESTS_MODULE_PATH .
2525
DIRECTORY_SEPARATOR .

docs/commands/mftf.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ vendor/bin/mftf build:project --MAGENTO_BASE_URL=http://magento.local/ --MAGENTO
105105

106106
#### Description
107107

108-
Generate PHP code from the tests defined in XML files.
108+
Perform XML schema validation and generate PHP code from the tests defined in XML files.
109109
The path is set in the `TESTS_MODULE_PATH` [configuration] parameter.
110110

111111
#### Usage
@@ -122,7 +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-
| `--debug` | Returns additional debug information (such as the filename where an error occurred) when test generation fails because of an invalid XML schema. This parameter takes extra processing time. Use it after test generation has failed once. |
125+
| `--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>|
126126
| `-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.|
127127

128128
#### Examples of the JSON configuration
@@ -295,6 +295,7 @@ vendor/bin/mftf run:group [--skip-generate|--remove] [--] <group1> [<group2>]
295295
| --------------------- | --------------------------------------------------------------------------------------------------------- |
296296
| `-k, --skip-generate` | Skips generating from the source XML. Instead, the command executes previously-generated groups of tests. |
297297
| `-r, --remove` | Removes previously generated suites and tests before the actual generation and run. |
298+
| `--debug or --debug=[<none>]`| Performs schema validations on XML files. `run:group` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release.|
298299

299300
#### Examples
300301

@@ -326,6 +327,7 @@ vendor/bin/mftf run:test [--skip-generate|--remove] [--] <name1> [<name2>]
326327
|-----------------------|-----------------------------------------------------------------------------------------------------------|
327328
| `-k, --skip-generate` | Skips generating from the source XML. Instead, the command executes previously-generated groups of tests. |
328329
| `-r, --remove` | Remove previously generated suites and tests. |
330+
| `--debug or --debug=[<none>]`| Performs schema validations on XML files. `run:test` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release.
329331

330332
#### Examples
331333

@@ -347,6 +349,11 @@ For more details about `failed`, refer to [Reporting][].
347349
```bash
348350
vendor/bin/mftf run:failed
349351
```
352+
#### Options
353+
354+
| Option | Description |
355+
|-----------------------|-----------------------------------------------------------------------------------------------------------|
356+
| `--debug or --debug=[<none>]`| Performs schema validations on XML files. `run:failed` implicitly performs schema validation on merged files. It does not indicate the file name where the error is encountered. `--debug` performs per-file validation and returns additional debug information (such as the filename where an error occurred). Use it after test run has failed once. `--debug=none` skips debugging during test run. Added for backward compatibility, it will be removed in the next MAJOR release.|
350357

351358
#### Examples
352359

docs/versioning.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ X.Y.Z
3030
| | +-- Backward Compatible changes (Patch release - bug fixes, small additions)
3131
| +---- Backward Compatible changes (Minor release - small new features, bug fixes)
3232
+------ Backward Incompatible changes (Major release - new features and/or major changes)
33-
3433
```
3534

3635
For example:
@@ -56,3 +55,14 @@ It MAY include patch level changes. Patch version MUST be reset to 0 when minor
5655
Major version **X** MUST be incremented for a release that introduces backward incompatible changes.
5756
A major release can also include minor and patch level changes.
5857
You must reset the patch and minor version to 0 when you change the major version.
58+
59+
## Magento 2 compatibility
60+
61+
This table lists the version of the MFTF that was released with a particular version of Magento.
62+
63+
|Magento version| MFTF version|
64+
|---|---|
65+
| 2.3.1 | 2.3.13 |
66+
| 2.3.0 | 2.3.9 |
67+
| 2.2.8 | 2.3.13 |
68+
| 2.2.7 | 2.3.8 |

src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php

+29-14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ class MftfApplicationConfig
1414
const UNIT_TEST_PHASE = "testing";
1515
const MFTF_PHASES = [self::GENERATION_PHASE, self::EXECUTION_PHASE, self::UNIT_TEST_PHASE];
1616

17+
/**
18+
* Mftf debug levels
19+
*/
20+
const LEVEL_DEFAULT = "default";
21+
const LEVEL_DEVELOPER = "developer";
22+
const LEVEL_NONE = "none";
23+
const MFTF_DEBUG_LEVEL = [self::LEVEL_DEFAULT, self::LEVEL_DEVELOPER, self::LEVEL_NONE];
24+
1725
/**
1826
* Determines whether the user has specified a force option for generation
1927
*
@@ -36,11 +44,11 @@ class MftfApplicationConfig
3644
private $verboseEnabled;
3745

3846
/**
39-
* Determines whether the user would like to execute mftf in a verbose run.
47+
* String which identifies the current debug level of mftf execution
4048
*
41-
* @var boolean
49+
* @var string
4250
*/
43-
private $debugEnabled;
51+
private $debugLevel;
4452

4553
/**
4654
* MftfApplicationConfig Singelton Instance
@@ -55,14 +63,14 @@ class MftfApplicationConfig
5563
* @param boolean $forceGenerate
5664
* @param string $phase
5765
* @param boolean $verboseEnabled
58-
* @param boolean $debugEnabled
66+
* @param string $debugLevel
5967
* @throws TestFrameworkException
6068
*/
6169
private function __construct(
6270
$forceGenerate = false,
6371
$phase = self::EXECUTION_PHASE,
6472
$verboseEnabled = null,
65-
$debugEnabled = null
73+
$debugLevel = self::LEVEL_NONE
6674
) {
6775
$this->forceGenerate = $forceGenerate;
6876

@@ -72,7 +80,15 @@ private function __construct(
7280

7381
$this->phase = $phase;
7482
$this->verboseEnabled = $verboseEnabled;
75-
$this->debugEnabled = $debugEnabled;
83+
switch ($debugLevel) {
84+
case self::LEVEL_DEVELOPER:
85+
case self::LEVEL_DEFAULT:
86+
case self::LEVEL_NONE:
87+
$this->debugLevel = $debugLevel;
88+
break;
89+
default:
90+
$this->debugLevel = self::LEVEL_DEVELOPER;
91+
}
7692
}
7793

7894
/**
@@ -82,14 +98,14 @@ private function __construct(
8298
* @param boolean $forceGenerate
8399
* @param string $phase
84100
* @param boolean $verboseEnabled
85-
* @param boolean $debugEnabled
101+
* @param string $debugLevel
86102
* @return void
87103
*/
88-
public static function create($forceGenerate, $phase, $verboseEnabled, $debugEnabled)
104+
public static function create($forceGenerate, $phase, $verboseEnabled, $debugLevel)
89105
{
90106
if (self::$MFTF_APPLICATION_CONTEXT == null) {
91107
self::$MFTF_APPLICATION_CONTEXT =
92-
new MftfApplicationConfig($forceGenerate, $phase, $verboseEnabled, $debugEnabled);
108+
new MftfApplicationConfig($forceGenerate, $phase, $verboseEnabled, $debugLevel);
93109
}
94110
}
95111

@@ -132,14 +148,13 @@ public function verboseEnabled()
132148
}
133149

134150
/**
135-
* Returns a boolean indicating whether the user has indicated a debug run, which will lengthy validation
136-
* with some extra error messaging to be run
151+
* Returns a string which indicates the debug level of mftf execution.
137152
*
138-
* @return boolean
153+
* @return string
139154
*/
140-
public function debugEnabled()
155+
public function getDebugLevel()
141156
{
142-
return $this->debugEnabled ?? getenv('MFTF_DEBUG');
157+
return $this->debugLevel ?? getenv('MFTF_DEBUG');
143158
}
144159

145160
/**

src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function readFiles($fileList)
157157
} else {
158158
$configMerger->merge($content);
159159
}
160-
if (MftfApplicationConfig::getConfig()->debugEnabled()) {
160+
if (MftfApplicationConfig::getConfig()->getDebugLevel() === MftfApplicationConfig::LEVEL_DEVELOPER) {
161161
$this->validateSchema($configMerger, $fileList->getFilename());
162162
}
163163
} catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) {
@@ -231,8 +231,14 @@ protected function validateSchema($configMerger, $filename = null)
231231
if ($this->validationState->isValidationRequired()) {
232232
$errors = [];
233233
if ($configMerger && !$configMerger->validate($this->schemaFile, $errors)) {
234-
$message = $filename ? $filename . PHP_EOL . "Invalid Document \n" : PHP_EOL . "Invalid Document \n";
235-
throw new \Exception($message . implode("\n", $errors));
234+
foreach ($errors as $error) {
235+
$error = str_replace(PHP_EOL, "", $error);
236+
LoggingUtil::getInstance()->getLogger(Filesystem::class)->criticalFailure(
237+
"Schema validation error ",
238+
($filename ? [ "file"=> $filename, "error" => $error]: ["error" => $error])
239+
);
240+
}
241+
throw new \Exception("Schema validation errors found in xml file(s)" . $filename);
236242
}
237243
}
238244
}

0 commit comments

Comments
 (0)