Before we deploy an application to production, we need to be sure it works correctly with the other
applications with
which it integrates. To do this, traditionally we run integration tests using "live", deployed applications.
Integration tests
- ✅ give us confidence to release
but
- ❌ introduce dependencies
- ❌ give slow feedback
- ❌ break easily
- ❌ require lots of maintenance
By testing each side of an integration point using a simulated version of the other application, we get two sets of
tests which
- ✅ run independently
- ✅ give fast feedback
- ✅ are stable
- ✅ are easy to maintain
but
- ❌ do not give us confidence to release.
This is because there is nothing to ensure that the simulated applications behave the same way as the real ones.
Pact solves the problem of keeping the two sets of tests in sync by use of a "contract", also known as a "pact".
During the consumer tests, each request made to a Pact mock provider is recorded into the contract file, along with
its expected response.
A Pact simulated consumer then replays each request against the real provider, and compares the actual and expected
responses. If they match, we have verified that the simulated applications behave the same way as the real
applications. This means the two real applications should communicate correctly when they interact in real life.
Using Pact gives you tests that
- ✅ run independently
- ✅ give fast feedback
- ✅ are stable
- ✅ are easy to maintain
and
- ✅ give you confidence to release
Once you have contract tests in place, you need a process to manage your contract testing process. This is where the Pact Broker comes in. The Pact Broker enables you to:
- ✅ Share and collaborate on contracts across teams
- ✅ Manage contracts across code branches and environments
- ✅ Orchestrate builds to know when it is safe to deploy
- ✅ Integrate into your processes and tooling
You can use PactFlow's hosted platform which takes care of hosting, related maintenance, security, team management and more.
There are two ways to run the Pact Broker. You can use PactFlow's hosted platform which takes care of hosting, related maintenance, security, team management and more.
Alternatively, you can host and maintain it yourself with the self-hosted open source Pact Broker.
PactFlow's free Starter Plan is a great way to kick-start a rapid proof of concept.