WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given how WordPress is written and how it interacts with a database and given how its not very much OOP oriented, is there a way to unit test a theme? is there a way unit test a framework (not a theme framework) that interacts with WordPress, that is, for example, can you write a unit test for dealing with the loop, dealing with the widgets?

If so does any one have any examples? I know how to write unit tests, but I have never tried to write one for a theme.


share|improve this question
up vote 5 down vote accepted

There is nothing stopping you from writing your own unit testing for themes/plugins using PHPUnit or some other testing platform.

As for WordPress, it has an official Unit Tests here:

There are several build scripts that can automate unit testing found here, including WP-CLI that have built in unit testing, though you have to obviously write your own code.

I also found this plugin today via scibu's twitter rant :)
There are a few more in the repo:

Also check out this: Tutorials for Unit-Testing in WordPress and for unit-test.svn.wordpress.org?

share|improve this answer

I wrote the Travis-CI powered PHPunit testing library for Jigoshop and Easy Digital Downloads both of which are Ecommerce WP plugins developed on Github. The library employed could be easily converted to work for themes. The nice thing about the Travis-CI powered suite is that we can use it to quickly test multiple PHP and WP versions. If you're theme is a premium theme, and thus putting it on a free Github repo isn't an option, the suite works on Private Github repos with Travis-CI.

Alternatively, you can use the one found in Jigoshop and use commandline powered PHPUnit.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.