Contract Testing with OpenAPI

Wait, is that really possible?

Beppe Catanese
Geek Culture

--

Contract testing has emerged as a trending topic for developers and teams working with APIs. There is already a pyramid of layers of testing, so do we need another one? What is special about it and what is the value?

But most importantly, from my OpenAPI specification can I implement contract testing?

In this article: let’s talk contract testing with OpenAPI. Is OpenAPI “ready” for contract testing? What are the options, challenges and opportunities?

The question at hand is whether it is possible to implement contract testing using an OpenAPI file. Let me answer this: the answer is no. However, if you continue reading, I will elaborate on the limitations and explore options to address them. 😎

Check out also Testcontainers with OpenAPI to see Contract Testing in action with TestContainers.

Photo by Duy Pham on Unsplash

What is Contract Testing

There is plenty of literature on contract testing, thanks to various tools that have made a breakthrough, with Pact as the leading example. For a clear and simple “getting started” you can start from here.

A good definition of contract testing is a testing technique that makes sure the API consumer and provider meet each other’s

--

--

Beppe Catanese
Geek Culture

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