Skip to content

Commit fbf85a7

Browse files
committed
MQE-1736: Modularity in MFTF tests
- CR Fixes
1 parent c44d5d8 commit fbf85a7

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

docs/guides/test-modularity.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ This refers to test materials being correctly owned by the right Magento module,
1616

1717
Since MFTF queries the Magento instance for enabled modules, MFTF test materials are included or excluded from the merging process dynamically, making proper ownership and dependencies a must.
1818

19+
Consider the following scenario:
20+
21+
* TestA in ModuleA is using materials form ModuleB
22+
* In Magento, I now disable ModuleB
23+
* TestA will try to use ModuleB materials, which are no longer being read by MFTF since the Magento instance has it disable
24+
25+
Since TestA's dependencies are out of sync with ModuleA, the tests are no longer properly modular.
26+
1927
## Why is test modularity important?
2028

2129
This concept is important simply because without proper modularity, tests or test materials may be incorrectly merged in (or left out), leading to the the test itself being out of sync with the Magento instance.
@@ -46,19 +54,30 @@ This approach will work on getting the quickest ownership, but it is fairly obvi
4654

4755
This is the next step up in difficulty from the above method, as it involves searching through the Magento codebase.
4856

49-
Take the `Add Attribute` button for example. The button has an `id="addAttribute"`, and searching through the codebase for `"addAttribute"` will lead you to `Catalog/view/adminhtml/ui_component/product_form.xml`:
57+
Take the `Add Attribute` button for example. The button has an `id="addAttribute"` and since we know Magento uses XML to declare much of its layout/CSS properties we can start by searching only `*.xml` files.
58+
59+
Searching through the codebase for `"addAttribute"` in `xml` files in my instance lead to four different files:
60+
61+
```
62+
app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerActivitiesConfigureSection.xml
63+
app/code/Magento/GiftRegistry/Test/Mftf/Section/AdminGiftRegistrySection.xml
64+
app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
65+
app/code/Magento/Catalog/view/adminhtml/ui_component/product_form.xml
66+
```
67+
68+
The first three are clearly MFTF test materials, which leaves us with the final file, and the line below
5069

5170
```xml
5271
<button name="addAttribute" class="Magento\Catalog\Block\Adminhtml\Product\Edit\Button\AddAttribute"/>
5372
```
5473

55-
This means that `Add Attribute` button belongs to Catalog based on the above class namespace and filepath.
74+
This means we can safely assume `Add Attribute` button belongs to Catalog based on the above class namespace and filepath.
5675

5776
This kind of deduction is more involved, but it much more likely to give you the true source of the element.
5877

5978
### Use bin/mftf static-checks
6079

61-
The second aspect of modular test materials involves test material references to other test materials, and making sure the dependencies are not out of sync with the parent module.
80+
For tests to be fully modular, an MFTF test must have the same dependencies as its parent module. This is quite difficult to do by hand, and requires checking of every `{{test.material}}` call and any other references to MFTF test materials in a test.
6281

6382
The `static-checks` command includes a test material ownership check that should help suss out these kind of dependency issues.
6483

0 commit comments

Comments
 (0)