# Contract Testing

> Tests that check an API and the apps that call it still agree.

**Field:** Software Development  
**Category:** APIs  
**Also known as:** Consumer-Driven Contract Testing, API Contract Test, Pact Testing

## Think of it like

Think of it like two people signing the same deal. Each one checks they keep their side of it.

## Definition

Contract testing checks that an API and the apps that call it still agree. The agreement is the contract: which requests are sent and which answers come back. The calling app is tested against the contract. The API is tested against the same contract. If either side breaks it, a test fails before anything ships.

## Example

Emma's app expects an order to have a total field. When Jack renames it on the server, the contract test fails before release.

## Why it matters

It catches changes that break other teams, without running the whole system.

## Common mistake

Thinking it tests that the API works well. It only tests that both sides agree on the shape.

## Three principles

- **One contract.** Requests and answers both sides expect.
- **Both sides tested.** Caller and API, apart.
- **Catch breaks early.** Before either side ships.

## Related terms

- [API Testing](https://learn.benibix.com/term/development/api-testing)
- [Mock Server](https://learn.benibix.com/term/development/mock-server)
- [API Versioning](https://learn.benibix.com/term/development/api-versioning)
- [Integration Test](https://learn.benibix.com/term/development/integration-test)
- [API-First Design](https://learn.benibix.com/term/development/api-first-design)

## Told apart from

- [Integration Test vs Contract Testing](https://learn.benibix.com/compare/integration-test-vs-contract-testing): An integration test runs two or more real parts together to see that they work. A contract test checks each side alone against a shared file of requests and answers. It does not need the other side to be running.

![Two panels. API testing: a test sends a request straight to the API, with no screen, and checks the status code, the body and the speed. Contract testing and mock servers, lit up: a frontend team tests against a mock server that copies the API, while the backend team is still building it. A shared contract file sits between them, and both sides are tested against it.](https://learn.benibix.com/diagrams/dev3-api-testing.svg)

---

Source: https://learn.benibix.com/term/development/contract-testing
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
