Integration testing

Integration tests are used to check how components work inside WordPress.

For the integration test setup, the best way to set it up is using either Codeception or WP-CLI.


If you don't have WP-CLI installed on your system, install it. You can find documentation on starting unit tests here.

Assuming you have a plugin on your testing environment, in the project root folder run

wp scaffold plugin-tests my-plugin

This will create several new files and folders in your plugin


To initialize the testing environment locally, go to your plugin directory and run the install script

bin/ wordpress_unit_tests root '' localhost latest

The install script first installs a copy of WordPress in the /tmp directory (by default) as well as the WordPress unit testing tools. Then it creates a database to be used while running tests. The parameters that are passed to set up the test database. Be sure that your mysql service is up and running if you're running tests outside VVV.

After that, you can run the plugin tests by writing


Useful links

Codeception for WordPress Four WordPress integration testing easy pieces Integration Tests with WordPress & PHPUnit