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

Add php unit watcher and update unit test docs #44681

Merged
merged 3 commits into from Feb 19, 2024

Conversation

chihsuan
Copy link
Member

@chihsuan chihsuan commented Feb 16, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

When writing unit tests, it's often necessary to run them multiple times to ensure they pass correctly.

In JavaScript, Jest offers a --watch mode, which monitors file changes and automatically runs tests. This feature proves invaluable during JS development and test writing.

This PR introduces the addition of the phpunit-watcher package to the composer.json file and commands to the package.json file. These additions enable tests to rerun automatically when files are modified. The woocommerce-payments repository has successfully utilized this package for some time.

Furthermore, this PR updates the unit test documentation to mandate the usage of the watcher and provides instructions for setting up the test environment using wp-env.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Review the changes
  2. Make sure you can run the tests by following the instructions in the updated docs https://github.com/woocommerce/woocommerce/blob/dev/add-php-unit-watcher-and-unit-test-docs/plugins/woocommerce/tests/README.md

Please note that, unlike Jest, phpunit-watcher is unable to automatically only rerun the tests that are affected by the changes. It reruns all the tests. This is a limitation of the package. I also noticed that it's a bit slow when typing in the terminal in interactive mode but it still works fine when you press enter.

Screen.Recording.2024-02-16.at.15.31.22.mov

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Add php unit watcher and update unit test docs

Comment

@chihsuan chihsuan self-assigned this Feb 16, 2024
@chihsuan chihsuan marked this pull request as ready for review February 16, 2024 07:57
Copy link
Contributor

github-actions bot commented Feb 16, 2024

Hi @moon0326, @ObliviousHarmony, @adrianduffell, @woocommerce/ghidorah, @woocommerce/vortex

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@chihsuan chihsuan requested a review from a team February 16, 2024 08:09
Copy link
Contributor

github-actions bot commented Feb 16, 2024

Test Results Summary

Commit SHA: f3ae306

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 36s
E2E Tests33000603369m 42s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

Copy link
Contributor

@moon0326 moon0326 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic!!

LGTM and tested well 👍 🚀

@chihsuan chihsuan closed this Feb 19, 2024
@chihsuan chihsuan reopened this Feb 19, 2024
@chihsuan chihsuan merged commit 0b55f4e into trunk Feb 19, 2024
56 checks passed
@chihsuan chihsuan deleted the dev/add-php-unit-watcher-and-unit-test-docs branch February 19, 2024 08:40
@github-actions github-actions bot added this to the 8.7.0 milestone Feb 19, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Feb 19, 2024
@Stojdza Stojdza added status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants