Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 8b6801a

Browse files
authored
Merge pull request #7951 from gabrieldagama/updating-testing-docs
Added Static and SemVer tests docs
2 parents 32f65b2 + b9b2816 commit 8b6801a

File tree

6 files changed

+106
-3
lines changed

6 files changed

+106
-3
lines changed

src/_data/main-nav.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@
179179
- label: Web API Functional Testing
180180
url: /get-started/web-api-functional-testing.html
181181

182-
-
183-
184182
- label: Functional Areas
185183
children:
186184

src/_data/toc/testing.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,16 @@ pages:
6262
children:
6363

6464
- label: '@dataProvider'
65-
url: /test/unit/annotations/data-provider.html
65+
url: /test/unit/annotations/data-provider.html
66+
67+
- label: Static Testing
68+
children:
69+
70+
- label: Running Static Tests
71+
url: /test/static/static_test_execution.html
72+
73+
- label: Semantic Version Checker
74+
children:
75+
76+
- label: Running SVC tool
77+
url: /test/svc/semver_test_execution.html
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
group: testing
3+
title: Running Static Tests
4+
functional_areas:
5+
- Testing
6+
- test
7+
---
8+
9+
Executing Magento 2 static tests is straightforward. They can be executed in several ways.
10+
11+
### Running static tests on all files
12+
13+
To run static tests on all files, navigate to the Magento base directory and execute the following command:
14+
15+
```bash
16+
bin/magento dev:test:run static
17+
```
18+
19+
### Running PHP static tests on a subset of files
20+
21+
To run the static tests on a subset of files, create a new testsuite for phpunit:
22+
23+
1. From the Magento base directory navigate to `dev/tests/static/testsuite/Magento/Test`
24+
25+
1. Create a copy of the `Php` folder on the same directory and rename it to `Local`
26+
27+
1. Navigate to `dev/tests/static/testsuite/Magento/Test/Local/_files/whitelist` and open `common.txt`
28+
29+
1. Replace the contents with the folder of the files that you want to test. For example:
30+
31+
```text
32+
# Format: <componentType=module|library|theme|language|*> <componentName> <globPattern> or simply <globPattern>
33+
app/code/Magento/CatalogSearch/Model/Search
34+
```
35+
36+
1. Create a copy of the `dev/tests/static/phpunit.xml.dist` file and call it `phpunit.xml`:
37+
38+
1. Add a new testsuite to the `dev/tests/static/phpunit.xml` file inside the `<testsuites>` node:
39+
40+
```xml
41+
<testsuites>
42+
...
43+
<testsuite name="Local Test Suite">
44+
<file>testsuite/Magento/Test/Local/LiveCodeTest.php</file>
45+
</testsuite>
46+
</testsuites>
47+
```
48+
49+
1. Navigate to the Magento base directory and run:
50+
51+
```bash
52+
./vendor/bin/phpunit --testsuite="Local Test Suite" -c dev/tests/static/phpunit.xml.dist
53+
```
54+
55+
As a result of this process, you can run PHP static tests on a subset of files. It is also possible to run other types of static tests by following the same process with other testsuites.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
group: testing
3+
title: Running Semantic Version Checker
4+
functional_areas:
5+
- Testing
6+
- test
7+
---
8+
9+
Executing the Magento 2 Semantic Version Checker is a simple process, but it requires an external tool.
10+
11+
### Running Semantic Version Checker on local changes
12+
13+
To run the Semantic Version Checker on local changes:
14+
15+
1. Clone the `magento-semver` tool to your local machine:
16+
17+
```bash
18+
git clone [email protected]:magento/magento-semver.git
19+
```
20+
21+
1. Navigate to the cloned repository and run `composer install` to install the project dependencies:
22+
23+
```bash
24+
cd magento-semver && composer install
25+
```
26+
27+
1. To run the Semantic Version Checker, we need one folder with the feature changes and another folder with mainline code (without changes), so you may need to clone the Magento repository to a separate folder to perform the comparison.
28+
29+
1. Navigate the `magento-semver` folder and run the Semantic Version Checker compare command:
30+
31+
```bash
32+
bin/svc compare ../magento2-mainline ../magento2
33+
```
34+
35+
The first parameter is the mainline code without any changes, and the second parameter is the path to the folder with your changes.
36+
The results of the Semantic Version Checker are outputted to the console.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../v2.3/test/static/static_test_execution.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../v2.3/test/svc/semver_test_execution.md

0 commit comments

Comments
 (0)