Easily Set Up Unit Tests For Your Plugin

One of the reasons so few people take the time to write unit tests for plugins they author is that it’s a chore to set everything up. Besides installing PHPUnit, you also have to set up the WordPress testing library, as well as the actual pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party tests configuration files.

If you’re running WP-CLIWP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/ https://make.wordpress.org/cli/ 0.9.0-alpha2 or later, there are commands that make the last two steps significantly easier. See the Plugin Unit Tests wiki page for up-to-date usage info.

You can check out the sample-plugin repo to see what a generated plugin looks like.

A shout-out to the people that contributed to benbalter/wordpress-plugin-tests is in order.