Skip to content

Commit 4ef4074

Browse files
committed
Merge remote-tracking branch 'origin/develop' into MQE-659
2 parents 1e12724 + e11a5d0 commit 4ef4074

22 files changed

+144
-70
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
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

Lines changed: 26 additions & 0 deletions
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

dev/tests/_bootstrap.php

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 11 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 12 additions & 2 deletions
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,9 +122,19 @@ 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=[<developer> or <none>]`| Set debug level to `default` when the option is not specified, to `developer` with `--debug developer` or `--debug`, to `none` with `--debug none` | |
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

128+
#### Debugging levels
129+
130+
You can run `generate:tests` with any of the following debug levels. XML schema validation errors will be logged as CRITICAL failures.
131+
132+
| Debug level | Description |
133+
| ---| --- |
134+
|`default` `[generate:tests]` | Perform XML schema validation on merged files. Does not indicate the file name where the error is encountered. Use `developer` level for enhanced debugging. |
135+
|`developer` `[generate:tests --debug or generate:tests --debug developer]` | Returns additional debug information (such as the filename where an error occurred) when test generation fails because of an invalid XML schema. Note: This option takes extra processing time. Use it after test generation has failed once. |
136+
|`none` `[generate:tests --debug none]`| Skip debugging during test generation. Added for backward compatibility, it will be removed with the next MAJOR release.|
137+
128138
#### Examples of the JSON configuration
129139

130140
The configuration to generate a single test with no suites:

docs/versioning.md

Lines changed: 11 additions & 1 deletion
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

Lines changed: 29 additions & 14 deletions
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

Lines changed: 9 additions & 3 deletions
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
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function readFiles($fileList)
2424
$exceptionCollector = new ExceptionCollector();
2525
/** @var \Magento\FunctionalTestingFramework\Test\Config\Dom $configMerger */
2626
$configMerger = null;
27+
$debugLevel = MftfApplicationConfig::getConfig()->getDebugLevel();
2728
foreach ($fileList as $key => $content) {
2829
//check if file is empty and continue to next if it is
2930
if (!parent::verifyFileEmpty($content, $fileList->getFilename())) {
@@ -40,16 +41,19 @@ public function readFiles($fileList)
4041
} else {
4142
$configMerger->merge($content, $fileList->getFilename(), $exceptionCollector);
4243
}
43-
if (MftfApplicationConfig::getConfig()->debugEnabled()) {
44+
// run per file validation with generate:tests -d
45+
if ($debugLevel == MftfApplicationConfig::LEVEL_DEVELOPER) {
4446
$this->validateSchema($configMerger, $fileList->getFilename());
4547
}
4648
} catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) {
4749
throw new \Exception("Invalid XML in file " . $key . ":\n" . $e->getMessage());
4850
}
4951
}
5052
$exceptionCollector->throwException();
51-
if ($fileList->valid()) {
52-
$this->validateSchema($configMerger, $fileList->getFilename());
53+
54+
//run validation on merged file with generate:tests
55+
if ($debugLevel == MftfApplicationConfig::LEVEL_DEFAULT) {
56+
$this->validateSchema($configMerger);
5357
}
5458

5559
$output = [];

src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
$force,
6868
MftfApplicationConfig::GENERATION_PHASE,
6969
false,
70-
false
70+
MftfApplicationConfig::LEVEL_NONE
7171
);
7272

7373
$allActionGroups = ActionGroupObjectHandler::getInstance()->getAllObjects();

0 commit comments

Comments
 (0)