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 #124

Merged
merged 55 commits into from
Jul 26, 2021
Merged

Functional tests for WP-CLI commands #124

merged 55 commits into from
Jul 26, 2021

Conversation

swissspidy
Copy link
Collaborator

@swissspidy swissspidy commented Nov 18, 2018

Description

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

So far this includes only a test for wp traduttore info, but not yet tests for the other commands.

For these, I think we need to figure out how to create a bunch of GlotPress projects with meta data etc. when running the tests. Ideally there would be some proper WP-CLI commands for that, but GlotPress doesn't currently provide any to do such CRUD operations. Perhaps we have to contribute these upstream...

That would make writing these tests way easier. An alternative was mentioned below:

You could just import a SQL dump or create a PHP file which is executed once and creates all the things.

Fixes #21.

How has this been tested?

By writing tests :-)

Types of changes
New functional tests for WP-CLI commands.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

@swissspidy

This comment has been minimized.

@swissspidy

This comment has been minimized.

@ocean90

This comment has been minimized.

@swissspidy
Copy link
Collaborator Author

With all the Behat stuff being in a separate package it's not that straightforward to do so. Plus you'd want to test things like wp traduttore project build --all without any projects around and other edge case scenarios.

Also it would benefit everyone else using GlotPress and WP-CLI 🙂

@swissspidy

This comment has been minimized.

@ocean90 ocean90 modified the milestones: 3.1.0, 3.2.0 Jul 20, 2020
szepeviktor
szepeviktor previously approved these changes Jul 8, 2021
@swissspidy swissspidy marked this pull request as ready for review July 9, 2021 09:24
@swissspidy swissspidy changed the title [WIP] Functional tests for WP-CLI commands Functional tests for WP-CLI commands Jul 9, 2021
@ocean90
Copy link
Member

ocean90 commented Jul 9, 2021

Is the code coverage working? Wondering since there's no change on https://app.codecov.io/gh/wearerequired/traduttore/compare/124.

@szepeviktor
Copy link
Contributor

Is the code coverage working?

The upload step in CI says

Reports have been successfully queued for processing at codecov.io/github/wearerequired/traduttore/commit/0a906c10bb9465558fc77a0cbadac3dfcb8f7706

And Codecov knows about our latest commit
https://github.com/wearerequired/traduttore/pull/124/checks?check_run_id=3027581945

@swissspidy
Copy link
Collaborator Author

Is the code coverage working?

The upload step in CI says

Reports have been successfully queued for processing at codecov.io/github/wearerequired/traduttore/commit/0a906c10bb9465558fc77a0cbadac3dfcb8f7706

And Codecov knows about our latest commit
#124 (checks)

Plus, locally the clover files are generated just fine and I can see the code coverage for InfoCommand and the like as expected.

Screenshot 2021-07-09 at 12 16 11

There must be something wrong with the paths in there or something.

I'll try to compare the output with the one from PHPUnit.

@swissspidy
Copy link
Collaborator Author

So strange 😕

Setting pcov.directory and pcov.exclude did definitely help and the coverage files now look more or less the same as when using Xdebug.

The only big difference I found between the coverage file from PHPUnit and the one from Behat is the namespace.

The former has namespace="Required\Traduttore" and <package name="Required\Traduttore"> everywhere, the one from Behat has namespace="global".

@ocean90
Copy link
Member

ocean90 commented Jul 9, 2021

fwiw: @schlessera did disable the codecov upload in ampproject/amp-wp@07a844f. The comment for the reason isn't clear to me though.

@swissspidy
Copy link
Collaborator Author

fwiw: @schlessera did disable the codecov upload in ampproject/amp-wp@07a844f. The comment for the reason isn't clear to me though.

Interesting! I don't see why merging wouldn't work though, as we usually merge multiple reports in the web-stories-wp repo and it works just fine there.

Copy link
Member

@ocean90 ocean90 left a comment

Choose a reason for hiding this comment

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

Let's merge this and see if we can fix the coverage upload in a follow-up PR.

@ocean90 ocean90 merged commit 2a7f279 into master Jul 26, 2021
@delete-merged-branch delete-merged-branch bot deleted the behat-tests branch July 26, 2021 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Behat tests
5 participants