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
This project contains some unit / integration tests, but phpunit is not listed in require-dev in composer.json. That means it's assuming that developers have it installed, but that means it's then making assumptions about which version is installed, and therefore what features can be used / not used in tests.
Note: The Travis config file actually already includes different versions of PHPUnit depending on which version of PHP is available.
Before just including phpunit as a require-dev dependency though, I want to put forward an extension of this idea:
A quick scan of the tests suggest that at least some of them are unit tests - that is, testing one function or method, without the need to bootstrap WP first. Even some of the other tests could easily have certain WP functions mocked, without needing to be full integration tests involving a database.
My preference, and suggestion, would be to use Brain Monkey, which includes phpunit as a dependency, but already has support for testing actions and filters, and monkey-patches PHP / WP functions.
This then allows there to be a distinction between unit tests (quick, standalone tests), and integration (requires WP to be bootstrapped), which can make running test suites much quicker. An example of the tests/ layout can be seen here, and you can see that the bootstrap.php only conditionally loads WP depending on which --testsuite is run.
The text was updated successfully, but these errors were encountered:
One of the good practices of software development is that dependencies are explicit and isolated.
This project contains some unit / integration tests, but
phpunit
is not listed inrequire-dev
incomposer.json
. That means it's assuming that developers have it installed, but that means it's then making assumptions about which version is installed, and therefore what features can be used / not used in tests.Note: The Travis config file actually already includes different versions of PHPUnit depending on which version of PHP is available.
Before just including
phpunit
as arequire-dev
dependency though, I want to put forward an extension of this idea:A quick scan of the tests suggest that at least some of them are unit tests - that is, testing one function or method, without the need to bootstrap WP first. Even some of the other tests could easily have certain WP functions mocked, without needing to be full integration tests involving a database.
My preference, and suggestion, would be to use Brain Monkey, which includes
phpunit
as a dependency, but already has support for testing actions and filters, and monkey-patches PHP / WP functions.This then allows there to be a distinction between unit tests (quick, standalone tests), and integration (requires WP to be bootstrapped), which can make running test suites much quicker. An example of the
tests/
layout can be seen here, and you can see that the bootstrap.php only conditionally loads WP depending on which--testsuite
is run.The text was updated successfully, but these errors were encountered: