Skip to content

Commit e32eac1

Browse files
committed
MQE-1963: Update XSD Schema to verify that file has only single entity
1 parent 55ac3b8 commit e32eac1

25 files changed

+734
-410
lines changed

docs/best-practices.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Check out our best practices below to ensure you are getting the absolute most o
77
1. [Action group] names should be sufficiently descriptive to inform a test writer of what the action group does and when it should be used.
88
Add additional explanation in annotations if needed.
99
2. Provide default values for the arguments that apply to your most common case scenarios.
10+
3. One `<actionGroup>` tag is allowed per action group XML file.
1011

1112
## `actionGroups` vs `extends`
1213

@@ -111,7 +112,8 @@ Use a lower case first letter for:
111112

112113
## Page object
113114

114-
Use [parameterized selectors] for constructing a selector when test specific or runtime generated information is needed.
115+
1. One `<page>` tag is allowed per page XML file.
116+
2. Use [parameterized selectors] for constructing a selector when test specific or runtime generated information is needed.
115117
Do not use them for static elements.
116118

117119
<span class="color:red">
@@ -149,6 +151,7 @@ Define these three elements and reference them by name in the tests.
149151
It helps to inform the reader of what you are testing and to yield a more descriptive Allure report.
150152
- Explain in comments unclear or tricky test steps.
151153
1. Refer to [sections] instead of writing selectors.
154+
1. One `<test>` tag is allowed per test XML file.
152155

153156
## Test step merging order
154157

docs/page.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ The following conventions apply to MFTF pages:
4545
- `<page>` name must be alphanumeric.
4646
- `*Page.xml` is stored in the _Page_ directory of a module.
4747
- The name format is `{Admin|Storefront}{PageDescription}Page.xml`.
48-
48+
- One `<page>` tag is allowed per page XML file.
49+
4950
The `.url` attribute is required when using the page for [actions] that require the URL argument.
5051

5152
## Page examples

docs/section.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ The following conventions apply to MFTF sections:
4848
- `*Section.xml` is stored in the _Section_ directory of a module.
4949
- The name format is `{Admin|Storefront}{SectionDescription}Section.xml`.
5050
- Camel case is used for `<section>` elements.
51-
They describe the function of the element rather than attempting to describe the selector used.
51+
They describe the function of the element rather than attempting to describe the selector used.
52+
- One `<section>` tag is allowed per section XML file.
5253

5354
## Example
5455

docs/suite.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The format of a suite:
5252

5353
- A suite must contain at least one `<include>`, or one `<exclude>`, or both.
5454
- Using `<before>` in a suite, you must add the corresponding `<after>` to restore the initial state of your testing instance.
55+
- One `<suite>` tag is allowed per suite XML file.
5556

5657
## Conditions
5758

docs/test.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ The following conventions apply to MFTF tests:
4949
* Each action and action group has its own identifier `<stepKey>` for reference purposes.
5050
* A test may have any number of [assertions][assertion] at any point within the `<test>`.
5151
* If `<test>` is included in `<suite>`, it **cannot be generated in isolation** to the rest of the contents of the suite (see [suites] for details).
52-
53-
Multiple `<test>` tags per XML file can make it hard to find and organize tags.
54-
To simplify, we generate one `test.php` file per `<test>` tag provided, though we support both single and multiple `<test>` tags per XML file.
52+
* One `<test>` tag is allowed per test XML file.
5553

5654
## Elements reference
5755

docs/test/action-groups.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The following conventions apply to MFTF action groups:
1515
- All action groups are declared in XML files and stored in the `<module>/Test/Mftf/ActionGroup/` directory.
1616
- Every file name ends with `ActionGroup` suffix. For exampe `LoginAsAdminActionGroup.xml`.
1717
- Action group name should be the same as file name without extension.
18-
- Single file should contain only one `<actionGroup>` node
18+
- One `<actionGroup>` tag is allowed per action group XML file.
1919

2020
The XML format for the `actionGroups` declaration is:
2121

etc/di.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@
7070

7171
<virtualType name="Magento\FunctionalTestingFramework\Config\SchemaLocator\Page" type="Magento\FunctionalTestingFramework\Config\SchemaLocator">
7272
<arguments>
73-
<argument name="schemaPath" xsi:type="string">Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd</argument>
73+
<argument name="schemaPath" xsi:type="string">Magento/FunctionalTestingFramework/Page/etc/mergedPageObject.xsd</argument>
7474
</arguments>
7575
</virtualType>
7676
<virtualType name="Magento\FunctionalTestingFramework\Config\SchemaLocator\Section" type="Magento\FunctionalTestingFramework\Config\SchemaLocator">
7777
<arguments>
78-
<argument name="schemaPath" xsi:type="string">Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd</argument>
78+
<argument name="schemaPath" xsi:type="string">Magento/FunctionalTestingFramework/Page/etc/mergedSectionObject.xsd</argument>
7979
</arguments>
8080
</virtualType>
8181
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\Page" type="Magento\FunctionalTestingFramework\Config\Reader\MftfFilesystem">
@@ -94,7 +94,7 @@
9494
</virtualType>
9595
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\Section" type="Magento\FunctionalTestingFramework\Config\Reader\MftfFilesystem">
9696
<arguments>
97-
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Module</argument>
97+
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Mask</argument>
9898
<argument name="converter" xsi:type="object">Magento\FunctionalTestingFramework\Config\Converter</argument>
9999
<argument name="schemaLocator" xsi:type="object">Magento\FunctionalTestingFramework\Config\SchemaLocator\Section</argument>
100100
<argument name="domDocumentClass" xsi:type="string">Magento\FunctionalTestingFramework\Page\Config\SectionDom</argument>
@@ -150,7 +150,7 @@
150150
</virtualType>
151151
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\DataProfile" type="Magento\FunctionalTestingFramework\Config\Reader\MftfFilesystem">
152152
<arguments>
153-
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Module</argument>
153+
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Mask</argument>
154154
<argument name="converter" xsi:type="object">Magento\FunctionalTestingFramework\Config\Converter</argument>
155155
<argument name="domDocumentClass" xsi:type="string">Magento\FunctionalTestingFramework\DataGenerator\Config\Dom</argument>
156156
<argument name="schemaLocator" xsi:type="object">Magento\FunctionalTestingFramework\Config\SchemaLocator\DataProfile</argument>
@@ -187,7 +187,7 @@
187187
</virtualType>
188188
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\Metadata" type="Magento\FunctionalTestingFramework\Config\Reader\MftfFilesystem">
189189
<arguments>
190-
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Module</argument>
190+
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Mask</argument>
191191
<argument name="converter" xsi:type="object">Magento\FunctionalTestingFramework\Config\Converter</argument>
192192
<argument name="domDocumentClass" xsi:type="string">Magento\FunctionalTestingFramework\DataGenerator\Config\OperationDom</argument>
193193
<argument name="schemaLocator" xsi:type="object">Magento\FunctionalTestingFramework\Config\SchemaLocator\Metadata</argument>
@@ -212,7 +212,7 @@
212212
</virtualType>
213213
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\TestData" type="Magento\FunctionalTestingFramework\Config\Reader\MftfFilesystem">
214214
<arguments>
215-
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Module</argument>
215+
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Mask</argument>
216216
<argument name="converter" xsi:type="object">Magento\FunctionalTestingFramework\Config\TestDataConverter</argument>
217217
<argument name="schemaLocator" xsi:type="object">Magento\FunctionalTestingFramework\Config\SchemaLocator\TestData</argument>
218218
<argument name="domDocumentClass" xsi:type="string">Magento\FunctionalTestingFramework\Test\Config\Dom</argument>
@@ -286,13 +286,13 @@
286286

287287
<virtualType name="Magento\FunctionalTestingFramework\Config\SchemaLocator\ActionGroup" type="Magento\FunctionalTestingFramework\Config\SchemaLocator">
288288
<arguments>
289-
<argument name="schemaPath" xsi:type="string">Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd</argument>
289+
<argument name="schemaPath" xsi:type="string">Magento/FunctionalTestingFramework/Test/etc/mergedActionGroupSchema.xsd</argument>
290290
</arguments>
291291
</virtualType>
292292

293293
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\ActionGroupData" type="Magento\FunctionalTestingFramework\Config\Reader\MftfFilesystem">
294294
<arguments>
295-
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Module</argument>
295+
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Mask</argument>
296296
<argument name="converter" xsi:type="object">Magento\FunctionalTestingFramework\Config\ActionGroupDataConverter</argument>
297297
<argument name="schemaLocator" xsi:type="object">Magento\FunctionalTestingFramework\Config\SchemaLocator\ActionGroup</argument>
298298
<argument name="domDocumentClass" xsi:type="string">Magento\FunctionalTestingFramework\Test\Config\ActionGroupDom</argument>
@@ -353,7 +353,7 @@
353353
</virtualType>
354354
<virtualType name="Magento\FunctionalTestingFramework\Config\SchemaLocator\SuiteData" type="Magento\FunctionalTestingFramework\Config\SchemaLocator">
355355
<arguments>
356-
<argument name="schemaPath" xsi:type="string">Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd</argument>
356+
<argument name="schemaPath" xsi:type="string">Magento/FunctionalTestingFramework/Suite/etc/mergedSuiteSchema.xsd</argument>
357357
</arguments>
358358
</virtualType>
359359
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\SuiteData" type="Magento\FunctionalTestingFramework\Config\Reader\Filesystem">

src/Magento/FunctionalTestingFramework/Console/BuildProjectCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function ($type, $buffer) use ($output) {
109109

110110
if ($input->getOption('upgrade')) {
111111
$upgradeCommand = new UpgradeTestsCommand();
112-
$upgradeOptions = new ArrayInput(['path' => FilePathFormatter::format(TESTS_MODULE_PATH)]);
112+
$upgradeOptions = new ArrayInput([]);
113113
$upgradeCommand->run($upgradeOptions, $output);
114114
}
115115
}

src/Magento/FunctionalTestingFramework/Console/UpgradeTestsCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ class UpgradeTestsCommand extends Command
3232
protected function configure()
3333
{
3434
$this->setName('upgrade:tests')
35-
->setDescription('This command will upgrade all tests in the provided path according to new MFTF Major version requirements.')
36-
->addArgument('path', InputArgument::REQUIRED, 'path to MFTF tests to upgrade');
35+
->setDescription(
36+
'This command will upgrade all installed mftf tests according to new MFTF Major version requirements.'
37+
);
3738
$this->upgradeScriptsList = new UpgradeScriptList();
3839
}
3940

@@ -49,10 +50,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
4950
{
5051
/** @var \Magento\FunctionalTestingFramework\Upgrade\UpgradeInterface[] $upgradeScriptObjects */
5152
$upgradeScriptObjects = $this->upgradeScriptsList->getUpgradeScripts();
52-
foreach ($upgradeScriptObjects as $upgradeScriptObject) {
53-
$upgradeOutput = $upgradeScriptObject->execute($input);
53+
foreach ($upgradeScriptObjects as $scriptName => $upgradeScriptObject) {
54+
$output->writeln('Running upgrade script: ' . $scriptName . PHP_EOL);
55+
$upgradeOutput = $upgradeScriptObject->execute($input, $output);
5456
LoggingUtil::getInstance()->getLogger(get_class($upgradeScriptObject))->info($upgradeOutput);
55-
$output->writeln($upgradeOutput);
57+
$output->writeln($upgradeOutput . PHP_EOL);
5658
}
5759
}
5860
}

src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd

Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,10 @@
77
-->
88

99
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
10-
<xs:annotation>
11-
<xs:documentation>The definition of a page object.</xs:documentation>
12-
</xs:annotation>
13-
14-
<xs:element name="pages">
15-
<xs:annotation>
16-
<xs:documentation>
17-
The root element for configuration data.
18-
</xs:documentation>
19-
</xs:annotation>
20-
<xs:complexType>
10+
<xs:redefine schemaLocation="mergedPageObject.xsd">
11+
<xs:complexType name="PageType">
2112
<xs:sequence>
22-
<xs:element ref="page" maxOccurs="unbounded" minOccurs="1">
13+
<xs:element ref="page" maxOccurs="1" minOccurs="1">
2314
<xs:annotation>
2415
<xs:documentation>
2516
Contains sequence of ui sections in a page.
@@ -28,89 +19,5 @@
2819
</xs:element>
2920
</xs:sequence>
3021
</xs:complexType>
31-
</xs:element>
32-
33-
<xs:element name="page">
34-
<xs:complexType>
35-
<xs:sequence>
36-
<xs:element ref="section" maxOccurs="unbounded" minOccurs="0">
37-
<xs:annotation>
38-
<xs:documentation>
39-
Contains sequence of ui elements.
40-
</xs:documentation>
41-
</xs:annotation>
42-
</xs:element>
43-
</xs:sequence>
44-
<xs:attribute type="notEmptyType" name="name" use="required">
45-
<xs:annotation>
46-
<xs:documentation>
47-
Unique page name identifier.
48-
</xs:documentation>
49-
</xs:annotation>
50-
</xs:attribute>
51-
<xs:attribute type="xs:string" name="deprecated">
52-
<xs:annotation>
53-
<xs:documentation>
54-
Message and flag which shows that entity is deprecated.
55-
</xs:documentation>
56-
</xs:annotation>
57-
</xs:attribute>
58-
59-
<xs:attribute type="notEmptyType" name="url" use="required">
60-
<xs:annotation>
61-
<xs:documentation>
62-
URL for the page. Do not include the hostname. For example: "/admin/customer/index/"
63-
</xs:documentation>
64-
</xs:annotation>
65-
</xs:attribute>
66-
<xs:attribute type="notEmptyType" name="module" use="required">
67-
<xs:annotation>
68-
<xs:documentation>
69-
The name of the module to which the page belongs. For example: "Magento_Catalog".
70-
</xs:documentation>
71-
</xs:annotation>
72-
</xs:attribute>
73-
<xs:attribute type="xs:boolean" name="parameterized" use="optional"/>
74-
<xs:attribute type="pageArea" name="area" use="required"/>
75-
<xs:attributeGroup ref="removeAttribute"/>
76-
<xs:attribute type="xs:string" name="filename"/>
77-
</xs:complexType>
78-
</xs:element>
79-
80-
<xs:element name="section">
81-
<xs:complexType>
82-
<xs:attribute type="notEmptyType" name="name" use="required">
83-
<xs:annotation>
84-
<xs:documentation>
85-
Unique section name identifier.
86-
</xs:documentation>
87-
</xs:annotation>
88-
</xs:attribute>
89-
<xs:attributeGroup ref="removeAttribute"/>
90-
</xs:complexType>
91-
</xs:element>
92-
93-
<xs:simpleType name="notEmptyType">
94-
<xs:restriction base="xs:string">
95-
<xs:minLength value="1" />
96-
</xs:restriction>
97-
</xs:simpleType>
98-
99-
<xs:attributeGroup name="removeAttribute">
100-
<xs:attribute type="xs:boolean" name="remove" use="optional" default="false">
101-
<xs:annotation>
102-
<xs:documentation>
103-
Set to true to remove this element during parsing.
104-
</xs:documentation>
105-
</xs:annotation>
106-
</xs:attribute>
107-
</xs:attributeGroup>
108-
109-
<xs:simpleType name="pageArea" final="restriction" >
110-
<xs:restriction base="xs:string">
111-
<xs:enumeration value="admin" />
112-
<xs:enumeration value="storefront" />
113-
<xs:enumeration value="external" />
114-
</xs:restriction>
115-
</xs:simpleType>
22+
</xs:redefine>
11623
</xs:schema>

0 commit comments

Comments
 (0)