Welcome to my blog series on the creation of a simple WordPress plug and the setup, configuration and process of running unit and integration tests on this plugin. I hope you find reading it as useful as I did writing it.
This series started with the first article as a stand-alone piece. As my list of WordPress development projects grew it became apparent to me that the addition of code testing was necessary to ensure the proper operation and quality of the code I was writing. People depend on that code. Lots of people.
As I undertook the tasks of adding user and integration testing to my process I mostly found two types of resources on the internet. First, program and package documentation. Great for answering ‘what’ but often a little thin on ‘why’ and ‘how’, especially since most of the testing tools are meant to run in a self chosen and assembled suite. Second, great articles on one slice of the testing process.
So I wrote the other eleven blog posts for two reasons: first, it greatly helped to organize my thoughts and reinforce and buttress my development process; second, I thought that other people who were looking to get into testing their WordPress stuff might find a basic, but comprehensive, examination of these topics useful. I include some cul-de-sacs I needed to back out of in favour of different approaches along with some mistakes I made along the way. This is the nature of development and I thought it more authentic to include some of these. (I didn’t include them all though. I make tons of mistakes and it would have been very fractured reading if I included them all.)
I examine the plugin and test code in some detail in the posts and include full code lists for most files. I have also tucked the final code in a github repo: https://github.com/twelch555/truucde-blog. Feel free to clone it if you want to follow along or adapt it for your own use.
Enjoy,
Troy Welch
-
TruUcde Rabbithole 01/12 : Whitelist, Blacklist and the Unit Testing Rabbit Hole
This is the story of coding the TruUcde WordPress plugin which enables Site Admins to add users outside of black/white list restrictions.
-
TruUcde Rabbithole 02/12 : Testing & Tooling Concepts
This post looks at some background concepts and the tools required for unit and integration testing.
-
TruUcde Rabbithole 03/12 : Development Setup
Testing and WordPress development occur in a context, I thought I would briefly outline my environment, development tools and point to some useful resources.
-
TruUcde Rabbithole 04/12 : Installing the Tools
A look at getting the tools necessary for php unit testing installed.
-
TruUcde Rabbithole 05/12 : Project and Tool config & Sanity Tests
Exploring configuration of unit testing tools and running sanity tests to make sure that everything is working.
-
TruUcde Rabbithole 06/12 : Code Coverage
Configuring PHPUnit for the display of code coverage reports.
-
TruUcde Rabbithole 07/12 : Testing approaches
A brief look at testing approaches and where they fit in the development process.
-
TruUcde Rabbithole 08/12 : Unit Testing
In this article we are going to look at the actually unit tests for the TruUcde plugin code.
-
TruUcde Rabbithole 09/12 : Setting up for integration testing
In this post we’ll set up and configure what is needed for WordPress integration tests.
-
TruUcde Rabbithole 10/12 : Setup and Integration Tests (Part 1)
In this article we’ll start by taking care of some final set up items and conduct sanity tests to see if our plugin is properly loading into WordPress.
-
TruUcde Rabbithole 11/12 : Integration Tests (Part 2)
In this article we’ll carry on with our examination of the integrations tests of the TruUcde plugin.
-
TruUcde Rabbithole 12/12 : I’m fixing a hole
This final article in the series looks at how testing can be useful when making code changes.