Overview

Contract testing allows for testing the integrations between services without having to run real services.

https://www.youtube.com/watch?v=IetyhDr48RI

The most prevalent tool/framework for conducting contract testing is PACT https://pact.io/ which works for almost all languages and frameworks.

Combining with a Pact Broker, this can help track and check the compatibilities between different versions of services to help prevent the problem of deploying incompatible versions into production.

Capabilities of PACT

Capability

Documentation

Spiked

Consumer Node JS - API

https://www.npmjs.com/package/@pact-foundation/pact#consumer-side-testing

Producer Node JS - API

https://www.npmjs.com/package/@pact-foundation/pact#provider-api-testing

Consumer Node JS - Async

https://www.npmjs.com/package/@pact-foundation/pact#asynchronous-api-testing

Producer Node JS - Async

https://www.npmjs.com/package/@pact-foundation/pact#provider-producer

Consumer JVM - API

https://github.com/pact-foundation/pact-jvm

Producer JVM - API

Consumer JVM - Async

❌ - In documentation, but not tried it.

Producer JVM - Async

❌ - In documentation, but not tried it.

JVM pact supports both Java and Kotlin.

Pact files are technology agnostic, so a pact file created by a NodeJS consumer can be used to verify a JVM producer and vice versa.

Pact testing for Flutter is still an unknown.

Capabilities of PACT Broker

Pact Broker (OSS - Free, self hosted) : https://github.com/pact-foundation/pact_broker

Pact Flow (Commercial - $$, managed hosting with self hosted option at “enterprise” level) : https://pactflow.io/

Main differences can be found here: https://pactflow.io/features/

Capability

Spiked

Capability

Spiked

Store consumer created file (versioned)

Provide consumer created pact file to verify producer

Record which producer and consumer combination have bee successfully verified

Allow to indicate which versions of which services have been deployed where

Allow to check a service version compatible with deployed services in an environment

Draw network diagram of services

Authentication and Authorisation

✅ - Supported in Pact Flow only, not supported in Pact Broker

OpenAPI based provider driven contract testing

❌ - Supported in Pact Flow only, not supported in Pact Broker - https://docs.pactflow.io/docs/workshops/bi-directional/contracts/oas/