Skip to content

Commit e8807e7

Browse files
committed
MQE-1736: Modularity in MFTF tests
- Added topic
1 parent ac6bad7 commit e8807e7

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

docs/guides/test-modularity.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Test Modularity
2+
3+
One of MFTF's most distinguishing functionalities is the framework's modularity.
4+
5+
## What is test modularity
6+
7+
Within MFTF, test modularity can refer to two different concepts:
8+
9+
### Test material merging
10+
11+
This concept is covered extensively in the [merging] topic, so it will not be our focus in this guide
12+
13+
### Modular test materials
14+
15+
This refers to test materials being correctly owned by the right Magento module, and for tests to have references to only what their parent Magento module has a dependency on.
16+
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+
19+
## Why is test modularity important?
20+
21+
This concept is important simply because without proper modularity, tests or test materials may be incorrectly merged in (or be left out), leading to the the test itself being out of sync with the Magento instance.
22+
23+
For example, in a situation where an extension drastically alters the login process (something like two factor authentication), the only way the tests will be able to pass is if the test materials are correctly nested in the extension.
24+
25+
## How can I achieve test modularity?
26+
27+
Test modularity can be challenging, depending on the breadth of the changes being introduced in a module.
28+
29+
### Determine test material ownership
30+
31+
This is should be the first step when creating new test materials. We will use the `New Product` page as an example.
32+
33+
#### Intuitive reasoning
34+
35+
The easiest way to do this has limited application, but some times it's fairly obvious where a test material comes from due to nomenclature or functionality.
36+
37+
For instance, the following `<select>` for `Tax Class` clearly belongs to the `Tax` module
38+
39+
```xml
40+
<select class="admin__control-select" name="product[tax_class_id]"/>
41+
```
42+
43+
This approach will work on getting the quickest ownership, but it's fairly obvious that it may be necessary to double check
44+
45+
#### Deduction
46+
47+
This is the next step up in difficulty from the above method, as it involves searching through the Magento codebase.
48+
49+
Let's 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`:
50+
```xml
51+
<button name="addAttribute" class="Magento\Catalog\Block\Adminhtml\Product\Edit\Button\AddAttribute"/>
52+
```
53+
54+
This means that `Add Attribute` button belongs to Catalog based on the above class namespace and filepath.
55+
56+
This kind of deduction is more involved, but it much more likely to give you the true source of the element.
57+
58+
### Use bin/mftf static-checks
59+
60+
The latter 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.
61+
62+
The `static-checks` command includes a test material ownership check that should help suss out these kind of dependency issues.
63+
64+
See [mftf commands] for more information.
65+
66+
<!-- Link definitions -->
67+
[merging]: ../merging.md
68+
[mftf commands]: ../commands/mftf.md

0 commit comments

Comments
 (0)