Skip to content

Commit 87d1cee

Browse files
authored
Merge pull request #641 from magento/lbajsarowicz-doc-rollup
Lbajsarowicz doc rollup
2 parents 7327be1 + 11955b0 commit 87d1cee

File tree

7 files changed

+152
-142
lines changed

7 files changed

+152
-142
lines changed

docs/best-practices.md

Lines changed: 50 additions & 14 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 a Test or Action Group.
11+
Instead of writing everything by yourself - use `extends` attribute to refer to existing element and customize it.
12+
13+
**Reusable Resources**
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 is a replacement provided for a 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 the Magento Core team and Contributors join forces to cover most of the features with tests, it is impossible to have this done quickly.
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

@@ -94,20 +129,20 @@ Use the _Foo.camelCase_ naming convention, which is similar to _Classes_ and _cl
94129

95130
Use an upper case first letter for:
96131

97-
- File names. Example: _StorefrontCreateCustomerTest.xml_
98-
- Test name attributes. Example: `<test name="TestAllTheThingsTest">`
99-
- Data entity names. Example: `<entity name="OutOfStockProduct">`
100-
- Page name. Example: `<page name="AdminLoginPage">`
101-
- Section name. Example: `<section name="AdminCategorySidebarActionSection">`
102-
- Action group name. Example: `<actionGroup name="LoginToAdminActionGroup">`
132+
* File names. Example: _StorefrontCreateCustomerTest.xml_
133+
* Test name attributes. Example: `<test name="TestAllTheThingsTest">`
134+
* Data entity names. Example: `<entity name="OutOfStockProduct">`
135+
* Page name. Example: `<page name="AdminLoginPage">`
136+
* Section name. Example: `<section name="AdminCategorySidebarActionSection">`
137+
* Action group name. Example: `<actionGroup name="LoginToAdminActionGroup">`
103138

104139
#### Lower case
105140

106141
Use a lower case first letter for:
107142

108-
- Data keys. Example: `<data key="firstName">`
109-
- Element names. Examples: `<element name="confirmDeleteButton"/>`
110-
- Step keys. For example: `<click selector="..." stepKey="clickLogin"/>`
143+
* Data keys. Example: `<data key="firstName">`
144+
* Element names. Examples: `<element name="confirmDeleteButton"/>`
145+
* Step keys. For example: `<click selector="..." stepKey="clickLogin"/>`
111146

112147
## Page object
113148

@@ -145,9 +180,9 @@ Define these three elements and reference them by name in the tests.
145180
1. Keep your tests short and granular for target testing, easier reviews, and easier merge conflict resolution.
146181
It also helps you to identify the cause of test failure.
147182
1. Use comments to keep tests readable and maintainable:
148-
- Keep the inline `<!-- XML comments -->` and [`<comment>`] tags up to date.
183+
* Keep the inline `<!-- XML comments -->` and [`<comment>`] tags up to date.
149184
It helps to inform the reader of what you are testing and to yield a more descriptive Allure report.
150-
- Explain in comments unclear or tricky test steps.
185+
* Explain in comments unclear or tricky test steps.
151186
1. Refer to [sections] instead of writing selectors.
152187

153188
## Test step merging order
@@ -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

docs/configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ Example:
3232
MAGENTO_BACKEND_NAME=admin_12346
3333
```
3434

35+
### MAGENTO_BACKEND_BASE_URL
36+
37+
(Optional) If you are running the Admin Panel on separate a domain, specify this value:
38+
39+
Example:
40+
41+
```conf
42+
MAGENTO_BACKEND_BASE_URL=https://admin.magento2.test
43+
```
44+
3545
### MAGENTO_ADMIN_USERNAME
3646

3747
The username that tests can use to access the Magento Admin page
124 KB
Loading

docs/introduction.md

Lines changed: 55 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,79 @@
11
# Introduction to the Magento Functional Testing Framework
22

3-
[Find your MFTF version][] of the MFTF.
3+
The Magento Functional Tesitng Framework (MFTF) is a framework used to perform automated end-to-end functional testing.
44

5-
The Magento Functional Testing Framework (MFTF) aims to replace the [Functional Testing Framework] in future releases.
6-
MFTF improves:
5+
## Goals
6+
7+
- To facilitate functional testing and minimize the effort it takes to perform regression testing.
8+
- Enable extension developers to provide the Functional Tests to offered extensions.
9+
- Ensuring a common standard of quality between Magento, Extension Developers and System Intergrators.
10+
11+
MFTF also focuses on
712

813
- **Traceability** for clear logging and reporting capabilities.
914
- **Modularity** to run tests based on installed modules and extensions.
1015
- **Customizability** for existing tests.
1116
- **Readability** using clear and declarative XML test steps.
1217
- **Maintainability** based on simple test creation and overall structure.
1318

14-
Because MFTF tests are written in XML, you no longer need to learn PHP to write tests.
19+
## Audience
1520

16-
<div class="bs-callout bs-callout-info" markdown="1">
17-
We are actively developing functional tests.
18-
Refer to `<magento_root>/app/code/<vendor_name>/<module_name>/Test/Mftf/` for examples.
19-
Check out the [MFTF Test Migration][] repo.
20-
</div>
21+
- **Contributors**: Tests build confidence about the results of changes introduced to the platform.
22+
- **Extension Developers**: Can adjust expected behaviour according to their customizations.
23+
- **System Integrators**: MFTF coverage provided out-of-the-box with Magento is solid base for Acceptance / Regression Tests.
2124

22-
## Audience
25+
## MFTF tests
26+
27+
The MFTF supports two different locations for storing the tests and test artifacts:
2328

24-
This MFTF guide is intended for Magento developers and software engineers, such as QA specialists, PHP developers, and system integrators.
29+
- `<magento_root>/app/code/<vendor_name>/<module_name>/Test/Mftf/` is the location of local, customized tests.
30+
- `<magento_root>/vendor/<vendor_name>/<module_name>/Test/Mftf/` is location of tests provided by Magento and vendors.
2531

26-
## Goals
32+
If you installed Magento with Composer, please refer to `vendor/magento/<module_dir>/Test/Mftf/` for examples.
33+
34+
### Directory Structure
2735

28-
The purpose of MFTF is to:
36+
The file structure under both of the both path cases is the same:
2937

30-
- Facilitate functional testing and minimize the effort it takes to perform regression testing.
31-
- Make it easier to support the extension and customization of tests via XML merging.
38+
```tree
39+
Test
40+
└── Mftf
41+
├── ActionGroup
42+
│   └── ...
43+
├── Data
44+
│   └── ...
45+
├── Metadata
46+
│   └── ...
47+
├── Page
48+
│   └── ...
49+
├── Section
50+
│   └── ...
51+
└── Test
52+
└── ...
53+
```
3254

33-
## Scope
55+
<div class="bs-callout bs-callout-info" markdown="1">
3456

35-
MFTF will enable you to:
57+
We are actively developing functional tests. Check out the [MFTF Test Migration][] repository.
3658

37-
- Test user interactions with web applications in testing.
38-
- Write functional tests located in `<magento_root>/app/code/<vendor_name>/<module_name>/Test/Mftf/`.
39-
- Cover basic functionality using out-of-the-box tests. You can test extended functionality using custom tests.
40-
- Automate regression testing.
59+
</div>
4160

4261
## Use cases
4362

44-
As a Magento developer, test changes, such as extended search functionality, a new form attribute, or new product tags.
63+
- Contributor: changes the core behaviour, fixing the annoing bug.
64+
He wants to have automated "supervisor" which is going to verify his work continuously across the stages of bug fixing. Finally, when fix is done - Functional Test is also proof of work done.
65+
- Extension Developer: offers extension that changes core behaviour.
66+
He can easily write new tests to make sure that after enabling the feature, Magento behaves properly. Everything with just extending existing tests. As a result he don't need to write coverage from scratch.
67+
- Integration Agency: maintains Client's e-commerce.
68+
They are able to customize tests delivered with Magento core to follow customizations implemented to Magento. After each upgrade they can just run the MFTF tests to know that no regression was introduced.
69+
70+
## MFTF output
4571

46-
As a software engineer, perform regression testing before release to ensure that Magento works as expected with new functionality.
72+
- Generated PHP Codeception tests
73+
- Codeception results and console logs
74+
- Screenshots and HTML failure report
75+
- Allure formatted XML results
76+
- Allure report dashboard of results
4777

4878
## Find your MFTF version
4979

@@ -52,22 +82,16 @@ There are two options to find out your MFTF version:
5282
- using the MFTF CLI
5383
- using the Composer CLI
5484

55-
### MFTF CLI
85+
All the Command Line commands needs to be executed from `<magento_root>`
5686

57-
```bash
58-
cd <magento_root>/
59-
```
87+
### MFTF CLI
6088

6189
```bash
6290
vendor/bin/mftf --version
6391
```
6492

6593
### Composer CLI
6694

67-
```bash
68-
cd <magento_root>/
69-
```
70-
7195
```bash
7296
composer show magento/magento2-functional-testing-framework
7397
```
@@ -89,41 +113,6 @@ utils // The test-running utilities.
89113
codeception.dist.yml // Codeception configuration (generated while running 'bin/mftf build:project')
90114
```
91115

92-
## MFTF output
93-
94-
- Generated PHP Codeception tests
95-
- Codeception results and console logs
96-
- Screenshots and HTML failure report
97-
- Allure formatted XML results
98-
- Allure report dashboard of results
99-
100-
## MFTF tests
101-
102-
The MFTF supports two different locations for storing the tests and test artifacts:
103-
104-
- `<magento_root>/app/code/<vendor_name>/<module_name>/Test/Mftf/` is the directory to create new tests.
105-
- `<magento_root>/vendor/<vendor_name>/<module_name>/Test/Mftf/` is the directory with the out of the box tests (fetched by the Composer).
106-
107-
All tests and test data from these locations are merged in the order indicated in the above list.
108-
109-
The file structure under the both path cases is the same:
110-
111-
```tree
112-
<Path>
113-
├── ActionGroup
114-
│   └── ...
115-
├── Data
116-
│   └── ...
117-
├── Metadata
118-
│   └── ...
119-
├── Page
120-
│   └── ...
121-
├── Section
122-
│   └── ...
123-
└── Test
124-
└── ...
125-
```
126-
127116
## MFTF on Github
128117

129118
Follow the [MFTF project] and [contribute on Github].

docs/merging.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ For example:
2727
Although a file name does not influence merging, we recommend using the same file names in merging updates.
2828
This makes it easier to search later on.
2929

30+
## Merging precedence
31+
32+
**Magento Functional Testing Framework** uses Module's `<sequence>` to merge all XML configurations into Codeception instructions. If there's no Sequence specified, MFTF would use:
33+
34+
1. Vendor modules (Magento & Vendors) located in `vendor/`
35+
1. Tests located in `app/code/*/*/Test/Mftf`
36+
37+
![Usual precedence for merging MFTF Tests and resources][mftfExtendingPrecedence image]
38+
3039
## Add a test
3140

3241
You cannot add another [`<test>`][tests] using merging functionality.
@@ -570,3 +579,4 @@ The `_defaultSample` results corresponds to:
570579
[`<sections>`]: ./section.md
571580
[`<tests>`]: ./test.md
572581
[`<action groups>`]: ./test/action-groups.md
582+
[mftfExtendingPrecedence image]: img/mftf-extending-precedence.png

0 commit comments

Comments
 (0)