You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know that wp_mock and WordPress core Unit tests work differently and it may not even be possible to have them run together.
I use both and like both. But there are certain tests for which I would prefer wp_mock and certain tests for which I would prefer WordPress core Unit tests. But unfortunately right now there is no way to configure both of them for a single plugin. You have to pick one and stick with it even if you can group all the 'mock' tests using a separate testsuite or phpunit group and invoke the separately from phpunit.
What I am suggesting is to have a way to setup both of them together for a plugin and invoke the appropriate framework and their tests using either phpunit's group or testsuite feature.
I know that there was some recent discussion about it and I am interested in knowing everyone's thoughts on it.
The text was updated successfully, but these errors were encountered:
This would be amazing but how would you even approach it?
If memory serves, once WordPress has been loaded by the core test suite, WP_Mock cannot mock core functions because they will have already been defined.
I looked into this a while back (albeit briefly) and the best I could come up with was to configure tests to run in separate processes and disable the preserve global state setting.
That effectively means you have to reload the bootstrap for every single test, however, which is far from ideal.
For now I have settled on configuring two test suites when I want to use both - each gets their own bootstrap file and I just have to be explicit about which I want to run when I call PHPUnit.
For now I have settled on configuring two test suites when I want to use both - each gets their own bootstrap file and I just have to be explicit about which I want to run when I call PHPUnit.
That's the way to make it work, unfortunately. The alternative is to run all tests using process isolation, but that causes some problems with the core test suite (it introduces a few race conditions with the database).
I know that wp_mock and WordPress core Unit tests work differently and it may not even be possible to have them run together.
I use both and like both. But there are certain tests for which I would prefer wp_mock and certain tests for which I would prefer WordPress core Unit tests. But unfortunately right now there is no way to configure both of them for a single plugin. You have to pick one and stick with it even if you can group all the 'mock' tests using a separate testsuite or phpunit group and invoke the separately from phpunit.
What I am suggesting is to have a way to setup both of them together for a plugin and invoke the appropriate framework and their tests using either phpunit's group or testsuite feature.
I know that there was some recent discussion about it and I am interested in knowing everyone's thoughts on it.
The text was updated successfully, but these errors were encountered: