Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Static and SemVer tests docs #7951

Merged
merged 18 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/_data/main-nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@
- label: Web API Functional Testing
url: /get-started/web-api-functional-testing.html

-

- label: Functional Areas
children:

Expand Down
14 changes: 13 additions & 1 deletion src/_data/toc/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,16 @@ pages:
children:

- label: '@dataProvider'
url: /test/unit/annotations/data-provider.html
url: /test/unit/annotations/data-provider.html

- label: Static Testing
children:

- label: Running Static Tests
url: /test/static/static_test_execution.html

- label: Semantic Version Checker
children:

- label: Running SVC tool
url: /test/svc/semver_test_execution.html
55 changes: 55 additions & 0 deletions src/guides/v2.3/test/static/static_test_execution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
group: testing
title: Running Static Tests
functional_areas:
- Testing
- test
---

Executing the Magento 2 static tests is straightforward. They can be executed in several ways.

### Running static tests on all files

To run static tests on all files, navigate to the Magento base directory and execute the following command:

```bash
./bin/magento dev:test:run static
```

### Running PHP static tests on a subset of files

To run the static tests on a subset of files, you will have to create a new testsuite for phpunit:

**Step 1.** Navigate to the Magento base directory and then to `dev/tests/static/testsuite/Magento/Test`

**Step 2.** Create a copy of the `Php` folder on the same directory and name it `Local`

**Step 3.** Navigate to `dev/tests/static/testsuite/Magento/Test/Local/_files/whitelist` and edit the `common.txt` file

**Step 4.** Replace the contents of this file with the folder of the files that you want to test, for example:

```text
# Format: <componentType=module|library|theme|language|*> <componentName> <globPattern> or simply <globPattern>
app/code/Magento/CatalogSearch/Model/Search
```

**Step 5.** Create a copy of the `dev/tests/static/phpunit.xml.dist` file and call it `phpunit.xml`:

**Step 6.** Add a new testsuite to the `dev/tests/static/phpunit.xml` file inside the `<testsuites>` node:

```xml
<testsuites>
...
<testsuite name="Local Test Suite">
<file>testsuite/Magento/Test/Local/LiveCodeTest.php</file>
</testsuite>
</testsuites>
```

**Step 7.** Navigate to the Magento base directory and run this command:

```bash
./vendor/bin/phpunit --testsuite="Local Test Suite" -c dev/tests/static/phpunit.xml.dist
```

As a result of this process you will be able to 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 but using other testsuites.
38 changes: 38 additions & 0 deletions src/guides/v2.3/test/svc/semver_test_execution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
group: testing
title: Running Semantic Version Checker
functional_areas:
- Testing
- test
---

Executing the Magento 2 Semantic Version Checker is a simple process, but it requires an external tool to be used.

### Running Semantic Version Checker on local changes

To run the Semantic Version Checker on local changes, you need to:

**Step 1.** Clone the `magento-semver` tool to your local machine:

```bash
git clone git@github.com:magento/magento-semver.git
```

**Step 2.** Navigate to the cloned repository and run composer install to install the project dependencies:

```bash
cd magento-semver && composer install
```

**Step 3.** In order to run the Semantic Version Checker we need to have 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.

**Step 4.** Navigate the `magento-semver` folder and run the Semantic Version Checker compare command:

```bash
.bin/svc compare ../magento2-mainline ../magento2
```

The first parameter is the mainline code without any changes, and the second parameter is the path to the Magento with your feature changes.

As a result of this command you will get the results of the Semantic Version Checker tool.
1 change: 1 addition & 0 deletions src/guides/v2.4/test/static/static_test_execution.md
1 change: 1 addition & 0 deletions src/guides/v2.4/test/svc/semver_test_execution.md