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
{{ message }}
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: guides/v2.2/test/testing.md
+85-14Lines changed: 85 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -4,52 +4,101 @@ title: Magento Testing Guide
4
4
landing-page: Testing Guide
5
5
---
6
6
7
-
When talking about testing in Magento 2, we have to distinguish between different test types.
7
+
Magento actively leverages various testing strategies to ensure product and code quality.
8
+
9
+
Product quality matters to the end-users working with the Magento storefront, admin panel, web APIs and CLI.
10
+
Product quality tests verify that the user gets expected results while interacting with the Magento system.
11
+
12
+
Code quality is important to developers working with Magento codebase including:
13
+
14
+
- System integrators
15
+
- Extension developers
16
+
- Magento core team
17
+
- Community contributors
18
+
19
+
Code quality matters for:
20
+
21
+
- Extensibility - It should be straightforward to extend or modify existing behavior.
22
+
Good extensibility allows for:
23
+
- Customizations and extensions using modularity of the platform.
24
+
- Evolution of the platform with new releases.
25
+
- Maintainability - It should be straightforward for developers to work within the Magento system.
26
+
It can be improved with:
27
+
- Complexity management - Reduce the learning curve and risk of adding new bugs.
28
+
- Automatic bug detection - Reduces total cost of ownership.
29
+
- Coding standards - Ensures consistency and readability.
30
+
31
+
Automated tests are required by [Magento definition of done][] for any code changes.
32
+
33
+
## Product Quality Tests
34
+
35
+
-[Magento Functional Testing Framework][] - Tests the storefront and admin panel UI.
36
+
-[Web API Functional][] - Tests the REST, SOAP, and GraphQL areas.
37
+
-[Integration][] - Ensures that all the parts work together seamlessly.
38
+
- Performance - Tracks changes in CPU, Memory and other metrics. Executed nightly for develop branches. Custom builds can be configured using [performance toolkit][].
39
+
- Client-side performance - Measures total page load times in the browser.
40
+
- Load - Tracks the trends of system behavior under the load. Executed internally for each release using scenarios defined in the [performance toolkit][]
41
+
- Upgrade - Ensures that a seamless upgrade is possible from previously released product versions to the new one. Executed internally for each release.
42
+
-[JavaScript][] - Tests JS modules and other JS portions of the UI. These tests are similar to integration tests used for server-side testing.
43
+
44
+
## Code Quality Tests
45
+
46
+
- Static
47
+
-[PhpCs][] - Warns developers about coding standard violations. It can be integrated into an IDE to analyze the code as soon as you write it.
48
+
-[PhpMd][] - Used for monitoring code complexity and potential bugs. Can be integrated with an IDE for instant feedback.
49
+
- Dependency - Prevents incorrect dependencies between modules.
50
+
- Legacy code - Prevents usage of the legacy functionality.
51
+
- Unit - Used for testing of isolated algorithms or discreet pieces of code.
52
+
- Extensibility - Ensures the system is extensible as designed. Extensibility tests can be written using [Integration][], [JavaScript][] and [Web API Functional][] testing frameworks.
53
+
- Backward-compatibility - Enforces [Magento backward compatibility policy][] at all levels including source code, database, message queue, and web API.
8
54
9
55
## Functional
10
56
11
57
Functional tests are mainly used for system tests at a very high level by remote controlling a browser. Magento is treated as a black box, and tests happen from a user perspective.
12
58
13
-
For more information, see the [Functional Testing Framework Guide]({{ page.baseurl }}/mtf/mtf_introduction.html){:target="_blank"}.
59
+
The [Magento Functional Testing Framework][] (MFTF) is the main way to do functional testing. It uses XML files to run browser testing.
14
60
15
-
{: .bs-callout .bs-callout-info }
16
-
We've released the new Magento Functional Testing Framework (MFTF) recently. [Check it out]({{ site.baseurl }}/mftf/2.2/introduction.html){:target="_blank"}.
61
+
The [Functional Testing Framework][] (FTF) is the original framework used for testing Magento. This uses PHP scripts to run browser testing.
62
+
This framework is no longer in development and all FTF tests are in the process of being [ported over][] to the MFTF.
63
+
Until the porting to MFTF is finished, the FTF can still be run to ensure complete functional testing coverage.
17
64
18
-
## API Functional
65
+
## API Functional
19
66
20
67
The Web {% glossarytooltip 786086f2-622b-4007-97fe-2c19e5283035 %}API{% endglossarytooltip %} testing framework enables you to test the Magento {% glossarytooltip 377dc0a3-b8a7-4dfa-808e-2de37e4c0029 %}Web API{% endglossarytooltip %} from the client application point of view.
21
68
22
-
For more information, see the [Web API functional testing]({{ page.baseurl }}/get-started/web-api-functional-testing.html){:target="_blank"}.
69
+
For more information, see the [Web API functional testing][].
23
70
24
71
## Integration
25
72
26
73
Integration tests run Magento {% glossarytooltip bf703ab1-ca4b-48f9-b2b7-16a81fd46e02 %}PHP{% endglossarytooltip %} code in varying degrees of isolation. They tend to be a lot more low-level then functional tests. Because they do not utilize a browser to execute the tests, they can be a lot more granular in what they test. They also tend to run a lot quicker then functional tests.
27
74
28
-
For more information, see [Running Integration Tests]({{ page.baseurl }}/test/integration/integration_test_execution.html){:target="_blank"}.
75
+
For more information, see [Running Integration Tests][].
29
76
30
77
## JavaScript
31
78
32
79
Much of the functionality in Magento 2 is provided with the help of sophisticated {% glossarytooltip 312b4baf-15f7-4968-944e-c814d53de218 %}JavaScript{% endglossarytooltip %}. JavaScript tests ensure the {% glossarytooltip b00459e5-a793-44dd-98d5-852ab33fc344 %}frontend{% endglossarytooltip %} portion of Magento functions as expected.
33
80
34
-
For more information, please see the [Extension Developer Guide on JavaScript Tests]({{ page.baseurl }}/test/js/test_js-unit.html){:target="_blank"}.
81
+
For more information, please see the [Extension Developer Guide on JavaScript Tests][].
35
82
36
83
## Static
37
84
38
-
Static code analysis checks that PHP code follows the Magento 2 coding standards and best practices. They usually are executed during continuous integration using the `bin/magento` tool.
85
+
Static code analysis checks that PHP code follows the Magento 2 coding standards and best practices.
86
+
They are executed during continuous integration using the `bin/magento` tool.
39
87
40
-
Please see the [`magento dev:tests:run`]({{ page.baseurl }}/config-guide/cli/config-cli-subcommands-test.html){:target="_blank"} documentation for more information, using the test type `static`.
88
+
Please see the [`magento dev:tests:run`][] documentation for more information, using the test type `static`.
41
89
42
90
## Unit
43
91
44
-
Unit tests are used to check a single unit of PHP code in isolation. They are usually written during development using [test-driven development](https://en.wikipedia.org/wiki/Test-driven_development){:target="_blank"} (TDD).
92
+
Unit tests are used to check a single unit of PHP code in isolation. They are usually written during development using [test-driven development][] (TDD).
45
93
46
94
Because they do not require the full Magento application stack to be initialized, they run an order of magnitude faster then integration tests.
47
95
48
-
For more information, see [Running Unit Tests]({{ page.baseurl }}/test/unit/unit_test_execution.html){:target="_blank"}.
96
+
For more information, see [Running Unit Tests][].
49
97
50
-
Please refer to the article [Writing testable code]({{ page.baseurl }}/test/unit/writing_testable_code.html){:target="_blank"} for more information on what to keep in mind when starting with TDD.
98
+
Please refer to the article [Writing testable code][] for more information on what to keep in mind when starting with TDD.
51
99
52
-
The `bin/magento` tool provides a common entry point to execute any of the tests, which can be useful for continuous integration. Please see the [System Administrators Guide on Running Tests]({{ page.baseurl }}/config-guide/cli/config-cli-subcommands-test.html){:target="_blank"} for more information.
100
+
The `bin/magento` tool provides a common entry point to execute any of the tests, which can be useful for continuous integration.
101
+
Please see the [System Administrators Guide on Running Tests][] for more information.
53
102
54
103
## Where to find the tests in the file system
55
104
@@ -65,3 +114,25 @@ Each of the test types listed above corresponds to a subdirectory in `<magento2
65
114
└── unit
66
115
67
116
Each one of these test types has different requirements that must be satisfied before they can be executed.
117
+
118
+
<!-- Link Definitions -->
119
+
[Magento definition of done]: https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing_dod.html
The Wishlist endpoint defines the contents of a customer's wish list.
7
+
8
+
## Query
9
+
Use Wishlist queries to retrieve information about a customer's wish list.
10
+
11
+
### Wish list attributes
12
+
13
+
Attribute | Data type | Description
14
+
--- | --- | ---
15
+
`items` | [Wishlistitem](#wishlistitem) | An array of items in the customer's wish list
16
+
`items_count` | Int | The number of items in the wish list
17
+
`name` | String | When multiple wish lists are enabled, the name the customer assigns to the wish list
18
+
`sharing_code` | String | An encrypted code that Magento uses to link to the wish list
19
+
`updated_at` | String | The time of the last modification to the wish list
20
+
21
+
### Wish list item attributes {#wishlistitem}
22
+
23
+
Attribute | Data type | Description
24
+
--- | --- | ---
25
+
`added_at` | String | The time when the customer added the item to the wish list
26
+
`description` | String | The customer's comment about this item
27
+
`id` | Int | The wish list item ID
28
+
`product` | <ahref="{{ page.baseurl }}/graphql/reference/products.html#ProductInterface">ProductInterface</a> | The ProductInterface contains attributes that are common to all types of products. Note that descriptions may not be available for custom and EAV attributes
29
+
`qty` | Float | The quantity of this wish list item
30
+
31
+
## Syntax
32
+
33
+
`wishlist: WishlistOutput`
34
+
35
+
## Example usage
36
+
37
+
The following query returns the customer's wish list:
0 commit comments