Testcontainers with OpenAPI

API integration testing with a contract-driven mock server

Beppe Catanese
Geek Culture

--

Testcontainers is an open-source multi-language framework that has revolutionised integration testing by leveraging containerisation.

The concept is simple yet powerful: developers define and spin up Docker containers directly from the test code. These containers serve as replicas of the dependencies utilised by the application, creating an effective environment for running integration tests.

Testcontainers offers an extensive selection of pre-configured containers, such as databases, message queues, and web servers. Additionally, it offers the flexibility to create new containers on the fly. This is a remarkable feature: developers can mock any dependency they require, including APIs under development.

And this is how I created a Testcontainer OpenAPI extension.

In this article: create a Testcontainer from an OpenAPI file, execute the integration testing leveraging the API contract, follow a step-by-step guide on how to test your API

Check out Contract Testing with OpenAPI to understand the challenges and solutions of Contract Testing with the OpenAPI standard.

Photo by Glen Carrie on Unsplash

Intro to Testcontainers

--

--

Beppe Catanese
Geek Culture

Developer Relations @ Adyen. Here sharing new trends, dev tools and best practises about APIs.