Integration testing

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

The best way set up an integration test is to use either Codeception or WP-CLI.


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

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

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