Skip to content

Commit d654bcb

Browse files
committed
Merge branch 'pr628' into lbajsarowicz-doc-rollup
2 parents 4376c4b + 8df17bf commit d654bcb

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

docs/best-practices.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,46 @@
22

33
Check out our best practices below to ensure you are getting the absolute most out of the Magento Functional Testing Framework.
44

5+
## Focus on reusability
6+
7+
### Use existing Tests and resources
8+
9+
Magento offers more than **3000** acceptance tests, **2500** [Action group]s, **750** Page declarations with more than **1500** Section definitions.
10+
It is very probable that behaviour you want to test already exists as other Test or Action Group.
11+
Instead of writing everything by yourself - try to use `extends` attribute to refer to existing element and customize it.
12+
13+
**Resources you can reuse**
14+
15+
* Tests (reusable with `<test extends="...">` argument)
16+
* Action Group (reusable with including `<actionGroup ref="...">`, or extending `<actionGroup extends="...">`)
17+
* Pages (reusable with reference `{{PageDefinition.url}}`)
18+
* Sections (reusable with reference `{{SectionDefinition.elementDefinition}}`)
19+
* Data Entities (reusable with reference `<createData entity="...">"` or extending `<entity extends="...">`)
20+
21+
<div class="bs-callout bs-callout-warning" markdown="1">
22+
23+
Avoid using resources that are marked as **Deprecated**. Usually there's a replacement provided for deprecated resource.
24+
25+
</div>
26+
27+
### Extract repetitive Actions
28+
29+
Instead of writing a few of Tests that perform mostly the same actions, you should thing about [Action group] that is a container for repetitive Actions.
30+
If each run needs different data, use `<arguments>` to inject necessary information.
31+
32+
We recommend to keep Action Groups having single responsibility, for example `AdminLoginActionGroup`, which expected outcome is being logged in as Administrator when [Action group] is executed.
33+
34+
## Contribute
35+
36+
Althought Magento Core team and Contributors join their forces to cover most of the features with tests, it's impossible to have this done that quick.
37+
If you've covered Magento Core feature with Functional Tests - you are more than welcome to contribute.
38+
39+
You can also help with [MFTF Test Migration] to get the experience and valuable feedback from other community members and maintainers.
40+
541
## Action group
642

7-
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.
8-
Add additional explanation in annotations if needed.
9-
2. Provide default values for the arguments that apply to your most common case scenarios.
43+
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. Add additional explanation in annotations if needed.
44+
1. Provide default values for the arguments that apply to your most common case scenarios.
1045

1146
## `actionGroups` vs `extends`
1247

@@ -175,3 +210,4 @@ Since the configurable product module could be disabled, this approach is more r
175210
[merging]: merging.html
176211
[parameterized selectors]: section/parameterized-selectors.html
177212
[sections]: section.html
213+
[MFTF Test Migration]: https://github.com/magento/magento-functional-tests-migration

0 commit comments

Comments
 (0)