From ef023f75c6685e5ec5ffa7646baf726b438558e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20L=C3=B3pez?= Date: Mon, 4 Sep 2023 15:07:32 +0200 Subject: [PATCH 1/4] Add instructions for testing contributions in the CONTRIBUTING.md file. --- .github/CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 63385a6a00f..e8d07fdc781 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -37,6 +37,10 @@ Please take a moment to review the [project readme](https://github.com/woocommer - Run our build process described in the document on [how to set up WooCommerce development environment](https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment), it will install our pre-commit hook, code sniffs, dependencies, and more. - Before pushing commits to GitHub, check your code against our code standards. For PHP code in the WooCommerce Core project you can do this by running `pnpm --filter=woocommerce run lint:php:changes:branch`. - Whenever possible, please fix pre-existing code standards errors in code that you change. +- Please consider adding appropriate tests related to your change if applicabble such as unit, API and E2E. You can check the following guides for this purpose: + - [Writing unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/README.md#writing-tests). + - [Writing API tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests#guide-for-writing-tests). + - [Writing E2E tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/e2e-pw#guide-for-writing-e2e-tests). - Ensure you use LF line endings in your code editor. Use [EditorConfig](http://editorconfig.org/) if your editor supports it so that indentation, line endings and other settings are auto configured. - When committing, reference your issue number (#1234) and include a note about the fix. - Ensure that your code supports the minimum supported versions of PHP and WordPress; this is shown at the top of the `readme.txt` file. From 30e2437d43e225ebc69727ece9742c666b6fea9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20L=C3=B3pez?= Date: Mon, 4 Sep 2023 15:12:02 +0200 Subject: [PATCH 2/4] Fix typo. --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e8d07fdc781..b2f1b02d04a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -37,7 +37,7 @@ Please take a moment to review the [project readme](https://github.com/woocommer - Run our build process described in the document on [how to set up WooCommerce development environment](https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment), it will install our pre-commit hook, code sniffs, dependencies, and more. - Before pushing commits to GitHub, check your code against our code standards. For PHP code in the WooCommerce Core project you can do this by running `pnpm --filter=woocommerce run lint:php:changes:branch`. - Whenever possible, please fix pre-existing code standards errors in code that you change. -- Please consider adding appropriate tests related to your change if applicabble such as unit, API and E2E. You can check the following guides for this purpose: +- Please consider adding appropriate tests related to your change if applicable such as unit, API and E2E. You can check the following guides for this purpose: - [Writing unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/README.md#writing-tests). - [Writing API tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests#guide-for-writing-tests). - [Writing E2E tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/e2e-pw#guide-for-writing-e2e-tests). From 6dc7b83c9c4a3fe32bd0996f2f8ebd46df4ae420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20L=C3=B3pez?= Date: Thu, 7 Sep 2023 13:56:38 +0200 Subject: [PATCH 3/4] Fix documentation based on feedback from PR review. --- .github/CONTRIBUTING.md | 6 +++--- plugins/woocommerce/tests/README.md | 8 ++++---- plugins/woocommerce/tests/api-core-tests/README.md | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b2f1b02d04a..b603f2378b8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -37,9 +37,9 @@ Please take a moment to review the [project readme](https://github.com/woocommer - Run our build process described in the document on [how to set up WooCommerce development environment](https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment), it will install our pre-commit hook, code sniffs, dependencies, and more. - Before pushing commits to GitHub, check your code against our code standards. For PHP code in the WooCommerce Core project you can do this by running `pnpm --filter=woocommerce run lint:php:changes:branch`. - Whenever possible, please fix pre-existing code standards errors in code that you change. -- Please consider adding appropriate tests related to your change if applicable such as unit, API and E2E. You can check the following guides for this purpose: - - [Writing unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/README.md#writing-tests). - - [Writing API tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests#guide-for-writing-tests). +- Please consider adding appropriate tests related to your change if applicable such as unit, API and E2E tests. You can check the following guides for this purpose: + - [Writing unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/README.md#guide-for-writing-unit-tests). + - [Writing API tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests#guide-for-writing-api-tests). - [Writing E2E tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/e2e-pw#guide-for-writing-e2e-tests). - Ensure you use LF line endings in your code editor. Use [EditorConfig](http://editorconfig.org/) if your editor supports it so that indentation, line endings and other settings are auto configured. - When committing, reference your issue number (#1234) and include a note about the fix. diff --git a/plugins/woocommerce/tests/README.md b/plugins/woocommerce/tests/README.md index 7d931f510e9..3390af5ac24 100644 --- a/plugins/woocommerce/tests/README.md +++ b/plugins/woocommerce/tests/README.md @@ -9,10 +9,10 @@ This document discusses unit tests. See [the e2e README](https://github.com/wooc - [Initial Setup](#initial-setup) - [MySQL database](#mysql-database) - [Setup instructions](#setup-instructions) - - [Running Tests](#running-tests) + - [Running Unit Tests](#running-unit-tests) - [Troubleshooting](#troubleshooting) - [Running tests in PHP 8](#running-tests-in-php-8) - - [Writing Tests](#writing-tests) + - [Guide for Writing Unit Tests](#guide-for-writing-unit-tests) - [Automated Tests](#automated-tests) - [Code Coverage](#code-coverage) @@ -51,7 +51,7 @@ Example: **Important**: The `` database will be created if it doesn't exist and all data will be removed during testing. -## Running Tests +## Running Unit Tests Change to the plugin root directory and type: @@ -97,7 +97,7 @@ $ tests/bin/install.sh woocommerce_tests_1 root root Note that `woocommerce_tests` changed to `woocommerce_tests_1` as the `woocommerce_tests` database already exists due to the prior command. -## Writing Tests +## Guide for Writing Unit Tests There are three different unit test directories: diff --git a/plugins/woocommerce/tests/api-core-tests/README.md b/plugins/woocommerce/tests/api-core-tests/README.md index db6e49ef917..747e672b086 100644 --- a/plugins/woocommerce/tests/api-core-tests/README.md +++ b/plugins/woocommerce/tests/api-core-tests/README.md @@ -8,7 +8,7 @@ This package contains automated API tests for WooCommerce, based on Playwright a - [Introduction](#introduction) - [About the Environment](#about-the-environment) - [Test Variables](#test-variables) -- [Guide for writing tests](#guide-for-writing-tests) +- [Guide for writing API tests](#guide-for-writing-api-tests) - [What aspects of the API should we test?](#what-aspects-of-the-api-should-we-test) - [Creating test structure](#creating-test-structure) - [Test Data Setup/Teardown](#test-data-setupteardown) @@ -130,7 +130,7 @@ After you run a test, it's best to restart the environment to start from a fresh - `pnpm env:destroy` when you make changes to `.wp-env.json` - `pnpm env:test` to spin up the test environment -## Guide for writing tests +## Guide for writing API tests When writing new tests, a good source on how to get started is to reference the [existing tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests/tests). Data that is required for the tests should be located in an equivalent file in the [data](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests/data) folder. From dcd05a7be3821ec58c1fccb3e06332709b878d11 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 7 Sep 2023 12:01:18 +0000 Subject: [PATCH 4/4] Add changefile(s) from automation for the following project(s): woocommerce --- .../changelog/add-instructions-for-testing-contribution | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 plugins/woocommerce/changelog/add-instructions-for-testing-contribution diff --git a/plugins/woocommerce/changelog/add-instructions-for-testing-contribution b/plugins/woocommerce/changelog/add-instructions-for-testing-contribution new file mode 100644 index 00000000000..630ac6debb2 --- /dev/null +++ b/plugins/woocommerce/changelog/add-instructions-for-testing-contribution @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Update CONTRIBUTING.md file to include instructions on how adding unit, API and E2E tests when applicable. + +