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

Functional tests for WP-CLI commands #215

Merged
merged 25 commits into from
Nov 8, 2023
Merged

Functional tests for WP-CLI commands #215

merged 25 commits into from
Nov 8, 2023

Conversation

swissspidy
Copy link
Member

@swissspidy swissspidy commented Jun 28, 2023

Description of the Change

This PR sets up the necessary infrastructure for running Behat tests for the built-in WP-CLI commands.

Also sets up code coverage, which is quite convenient.

How to test the Change

Run the tests locally or check out the CI build status.

Changelog Entry

Added - Functional tests for WP-CLI command

Credits

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@codecov-commenter

This comment was marked as outdated.

@swissspidy swissspidy marked this pull request as ready for review June 30, 2023 13:49
Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thank you, @swissspidy, for the PR. I have reviewed it initially and would like to discuss a few questions:

  • Do we have any plans to add new tests in Behat?
  • Considering that Behat uses Gherkin syntax, there might be a learning curve for us. How do we plan to address this?
  • Are we going to maintain both Unit tests and Behat tests simultaneously?

@swissspidy
Copy link
Member Author

Great questions!

  • Do we have any plans to add new tests in Behat?

Right now this PR just lays the foundation for the tests. New tickets can be created to add a few more tests. Not too many tests are needed because the command is rather straightforward and only has a few options.

  • Considering that Behat uses Gherkin syntax, there might be a learning curve for us. How do we plan to address this?

Luckily the syntax is pretty easy to grasp, making it easy to understand and write tests, plus there's plenty of documentation and tutorials out there. And of course I'm happy to do an intro as well if there's interest.

  • Are we going to maintain both Unit tests and Behat tests simultaneously?

Yes, these tests are an addition to the existing PHPUnit-based tests in the repo, focusing on how users interact with the WP-CLI command. There is little overlap. Just like e2e tests and unit/integration tests are not mutually exclusive. So I guess these could be seen as e2e tests for the WP-CLI command :-)

@spacedmonkey spacedmonkey self-requested a review July 14, 2023 14:37
@codecov
Copy link

codecov bot commented Oct 30, 2023

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

@swissspidy swissspidy removed the request for review from jjgrainger October 30, 2023 16:48
@swissspidy swissspidy added the [Type] Enhancement A suggestion for improvement of an existing feature label Oct 30, 2023
@swissspidy swissspidy added Infrastructure Issues for the overall plugin infrastructure WP-CLI Issues related to WP-CLI and removed [Type] Enhancement A suggestion for improvement of an existing feature labels Oct 31, 2023
@swissspidy
Copy link
Member Author

@felixarntz @westonruter @joemcgill @mukeshpanchal27 Pinging you since this PR has been around for a long time but it's still valuable — this adds some initial Behat tests for the WP-CLI command added by this plugin.

We need this to ensure the command works properly, especially when making changes. Also with #153 in mind.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thanks @swissspidy, LGTM.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@swissspidy LGTM, just one question before merge.

tests/behat/includes/FeatureContext.php Show resolved Hide resolved
@swissspidy swissspidy requested a review from felixarntz November 6, 2023 17:22
@felixarntz felixarntz merged commit db28ffe into trunk Nov 8, 2023
24 checks passed
@felixarntz felixarntz deleted the add/cli-tests branch November 8, 2023 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issues for the overall plugin infrastructure WP-CLI Issues related to WP-CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants