Title: Easily Set Up Unit Tests For Your Plugin
Author: scribu
Published: February 19, 2013

---

 [  ](https://profiles.wordpress.org/scribu/) [scribu](https://profiles.wordpress.org/scribu/)
12:00 am _on_ February 19, 2013      

# Easily Set Up Unit Tests For Your Plugin

One of the reasons so few people take the time to write [unit tests for plugins](http://wordpress.tv/2011/08/20/nikolay-bachiyski-unit-testing-will-change-your-life/)
they author is that it’s a chore to set everything up. Besides installing [PHPUnit](http://www.phpunit.de/manual/current/en/automating-tests.html),
you also have to set up the [WordPress testing library](https://make.wordpress.org/core/handbook/automated-testing/),
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/](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/](http://wp-cli.org/) [https://make.wordpress.org/cli/](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](https://github.com/wp-cli/wp-cli/wiki/Plugin-Unit-Tests)
wiki page for up-to-date usage info.

You can check out the [sample-plugin](https://github.com/wp-cli/sample-plugin) repo
to see what a generated plugin looks like.

A shout-out to the people that contributed to [benbalter/wordpress-plugin-tests](https://github.com/benbalter/wordpress-plugin-tests/contributors)
is in order.

### Share this:

 * [  Threads ](https://make.wordpress.org/cli/2013/02/19/plugin-unit-tests/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/cli/2013/02/19/plugin-unit-tests/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/cli/2013/02/19/plugin-unit-tests/?share=bluesky)
 * [  Facebook ](https://make.wordpress.org/cli/2013/02/19/plugin-unit-tests/?share=facebook)
 * [  X ](https://make.wordpress.org/cli/2013/02/19/plugin-unit-tests/?share=x)
 * [  LinkedIn ](https://make.wordpress.org/cli/2013/02/19/plugin-unit-tests/?share=linkedin)

 * [Login to Reply](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fcli%2F2013%2F02%2F19%2Fplugin-unit-tests%2F%23respond&locale=en_US)

### Leave a Reply 󠀁[Cancel reply](https://make.wordpress.org/cli/2013/02/19/plugin-unit-tests/?output_format=md#respond)󠁿

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fcli%2F2013%2F02%2F19%2Fplugin-unit-tests%2F&locale=en_US)
to post a comment.

# Post navigation

[← Version 0.8](https://make.wordpress.org/cli/2013/01/26/version-0-8/)

[Edit WordPress Posts in Vim or Emacs or Whatever →](https://make.wordpress.org/cli/2013/03/16/editing-posts/)