I think we can all agree that unit testing is pretty neat.
An automated system for checking if your code changes break any functionality is almost magic, and if you aren’t sure where to get started with it, you should read my previous post Unit Testing Your Plugins.
If you’ve spent some time on Github, you’ve probably heard of TravisCI, a continuous integration service that automatically runs tests for every commit and pull request on your repository. It’s super cool, very easy to set up, and free for open source projects.
One of the best parts of TravisCI is its ability to run your tests in multiple environments. In one go, you can test your plugin on several versions of PHP and WordPress and catch edge cases you might run into in versions you don’t develop on.
Our plugin generator by default sets up a TravisCI configuration so without any work on your part you can have your plugin tested on multiple environments for every commit. The one issue with TravisCI is you can’t easily run these tests locally, so you won’t have an idea of if your tests will run properly on all environments until they are pushed to GitHub.
Dockunit is like a offline TravisCI. It uses Docker to create local compartmentalized testing environments so you can easily run your tests on whatever setup you want. Docker is a container based system for running applications bundled with their dependencies. I’m doing a poor job of explaining it fully, but it’s really interesting and if you like virtualization and dev ops stuff you should take a look.