Episode 021: End to End & Integration Testing a REST API

In this episode we continue to use Test Driven Development (TDD) to drive out the implementation the simple HTTP REST(ish) API microservice in PHP.

We add a new endpoint GET to retrieve a book by its ISBN.

Starting with an End to End Test write using PHP Unit and Guzzle HTTP Client for PHP to design out how consumers of the API will interact with the endpoint.
We then add an Integration test to ensure our code uses Doctrine PHP ORM to interact with the Postgres database to get the book data.

Finally we add a Unit Test to the Book object to enable it to render itself into JSON using PHP’s JsonSerializable interface.

Don’t miss the excellent demonstration why we need to use different types of test at 33.15 the moment all the Unit Tests pass and the End to End Tests still fails

The code produced during this episode can be found on GitHub

Episode 004 – Mock Test Doubles

In Episode 4 of Testing All The Things we continue to create the driving licence generator we started in the previous two videos. In this video we create a mock random number generator to create random digits to the end of the driving licence number.

You can find all the Test Double code in this GitHub repository or just the code created for the spy functionality in this commit

Episode 003 – Spy Test Doubles

In this episode 3 of Testing All The Things we continue to look at different types of Test Double.

In the second video on test doubles we look at Spy Test Doubles.

You can find all the Test Double code in this GitHub repository or just the code created for the spy functionality in this commit.

Episode 002 – Stub Test Doubles

In episode 2 of Testing All The Things we start to exploring Test Doubles. Test doubles are used to isolate the code under test from its dependencies. Test doubles imitate the functionality of a dependency.

Creating test doubles do not require the use of a mocking framework. In the following videos we will not use a mocking framework so we can concentrate of the theory.

In the first video we are looking at the simplest form of Test Double, Stubs.