You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/test-modularity.md
+22-3Lines changed: 22 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,14 @@ This refers to test materials being correctly owned by the right Magento module,
16
16
17
17
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.
18
18
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
+
19
27
## Why is test modularity important?
20
28
21
29
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
46
54
47
55
This is the next step up in difficulty from the above method, as it involves searching through the Magento codebase.
48
56
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:
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.
56
75
57
76
This kind of deduction is more involved, but it much more likely to give you the true source of the element.
58
77
59
78
### Use bin/mftf static-checks
60
79
61
-
The second aspect of modulartest 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.
62
81
63
82
The `static-checks` command includes a test material ownership check that should help suss out these kind of dependency issues.
0 commit comments