Testing WordPress Plugins with Codeception on Bitbucket Pipelines using Docker Compose

This year I’ve started to use Codeception as an alternative to vanilla PHPUnit for testing WordPress plugins. I’m using the fantastic WP-Browser library written by Luca Tumedei. It makes writing WordPress acceptance tests sane by providing a suite of Codeception Modules to load WordPress and simulate WordPress APIs.

At iThemes we host all of our repositories on Bitbucket which made Bitbucket Pipelines a natural choice for automatically running our Codeception tests on commit. Getting everything up and running took a bit of work and wasn’t always straightforward. I intend for this post to be a guide to testing WordPress plugins with Codeception on Bitbucket Pipelines that’ll hopefully save you some time if you’re trying to set this up for yourself.


JSON Schema and the WP REST API

JSON Schema is a draft IETF specification that provides a vocabulary that allows you to annotate and validate JSON documents – json-schema.org. The WordPress REST API utilizes this system for describing the request and response formats for each endpoint. The schema for any endpoint can be seen by making an OPTIONS request to the endpoint.