Episode 020 – End to End Testing (REST API)

In this episode of Testing All The Things we start to use Test Driven Development (TDD) to drive out the implementation the simple HTTP REST(ish) API microservice in PHP.

The first feature we add is a new endpoint to GET the health of the API microservice. Starting with an End to End Test write using PHPUnit and Guzzle HTTP Client for PHP to design out how consumers of the API will interact with the /health endpoint.

The second feature was to handle requests where the route could not be matched and return a HTTP 404 Not Found. Again we start with an End to End Test to drive out how API consumers will interact with the Microservice. We then move on to unit testing the implementation of a ErrorRendererInterface from the Slim Framework. Finally we plug in our ErrorRenderer into the Slim application to make all the tests pass.

The code produced during this episode can be found on GitHub