Unit Testing in WordPress: Items API

Unit Testing in WordPress: Items API

If you’ve been following along with Simmer’s development, you know that we recently released version 1.3 to the world. This version brought on a major refactor of the plugin’s data and file structure in an effort to make recipe information more extendable.

Simmer 1.3 Items API

We decided to move recipe ingredients and instructions data into their own database table and create the new Items API, which opens up endless possibilities for our team, as well as third-parties to extend in the future. And as you can imagine, we tested the heck out of it. Since we were facing converting existing user data on upgrade, we made sure to rigorously test the upgrade process to prevent any major data loss and for the most part, we were successful.

But in all of our testing of the newly refactored plugin, we failed to test a key component of the whole Simmer experience: plugin uninstall. Granted, we hope that as we continue to improve Simmer that fewer and fewer people will want to uninstall it, but it’s a critical component nonetheless. It’s also one of those aspects that we plugin developers can sometimes forget about. We have our local environments for developing and testing, but how often does uninstalling the working copy of our plugin come to mind?

So after a long dev cycle we released v1.3.0 and celebrated, only to be greeted with a couple of support requests claiming a fatal error and an inability to uninstall the plugin. Not good! We quickly released a couple of patches and all is well, but it’s not something our development team would like to see happen again, that’s for sure.

We’ve learned that when developing any product, proprietary or open source: you should always. test. everything. Really get into those nooks and crannies and be sure that any code change, no matter how small, doesn’t unexpectedly affect some other small (or large) piece of your WordPress puzzle that you haven’t needed to think about for some time.

Unit testing a WordPress open source plugin

One great thing that’s come out of the 1.3 experience is that we are now going to put a heavy priority on setting up unit tests for the each next major release. Unit testing is something we are just starting to familiarize ourselves with, but its importance is clear. I suspect that the next post in this series will focus on our successes and tribulations with this method of testing, so stay tuned!

Lara Littlefield

Lara Littlefield has created software products for sale to businesses and consumers since 1999. She currently leads Simmer as Chief Engineer.

The recipe plugin everyone can use.

Get more traffic and revenue with the exclusive SEO and design in Simmer Pro. Give your visitors or customers a recipe experience they'll return to again and again.

Try Buy
Top