Tag Archives: Unit Testing

How do you start unit testing existing WordPress code?

A lot of us have heard about unit testing. Out of all the different types of testing (and there are a few!), it’s probably the better-known one. It’s also the most common form of testing used with WordPress.

In the past, we’ve looked at how unit testing works with WordPress. That said, knowing how unit testing works is one thing. This knowledge doesn’t necessarily make it any easier to get started with it in your projects.

Some of us work with existing code bases. It could be a plugin, a theme or a whole WordPress site. How do you take the fundamentals of unit testing and apply them in that context?

This is a tricky question to answer, but it’s also an important one. Most of us will not start using unit testing in a vacuum. We’re going to start using it with one of those existing code bases.

This brings with it its own unique sets of challenges. It also means that you need to have a strategy for them. This will help make this transition smoother for you.

Continue reading How do you start unit testing existing WordPress code?

Continuous deployment to the WordPress directory with CircleCI

Note: This article focuses on how to continuously deploy a plugin using CircleCI. But you can also use everything discussed here with a theme as well.

As developers, we all have our preferred tools and distinct way of working. That’s why it’s not uncommon for us to write about it or create scripts to set up our work computers. But the one tool that most of us tend to agree on is using git for version control.

That said, if you’ve ever had a plugin or theme on the WordPress directory, you know that it doesn’t use git. It uses subversion. That’s a problem for a lot of us because we don’t want to have to deal with both.

While there are a lot of resources out there to deal with this problem, it also presents us with an opportunity. We can use this problem to build a continuous deployment workflow for the WordPress directory. This will allow us to not worry about this aspect of WordPress plugin development anymore.

Continue reading Continuous deployment to the WordPress directory with CircleCI

Introduction to WordPress unit testing

I gave a talk at WordCamp Toronto 2015 on WordPress unit testing. This is the companion article that I wrote for it. If you’re just looking for the slides, click here.

“But this worked the other day!”

I don’t know about you, but reading that sentence just frustrates me! Don’t you hate when things worked one day and it doesn’t the next. It’s the stuff of (developer) nightmares.

What if there was a way to ward yourself against that evil? Well, you’re in luck because that’s the goal of software testing! It prevents this situation from happening over and over again. On top of that, it helps you improve the quality of the code you write. Awesome!

Now, software testing is a HUGE field. You have a ton of different types of testing. Each with its own purpose (and, sometimes, philosophy). Today, we’re going to focus on just one type of testing. It’s called unit testing.

Continue reading Introduction to WordPress unit testing