Skip to content
BENIBIX Learn

Contract Testing

Development🔌 APIsAPI Test Methods

Also known as Consumer-Driven Contract Testing, API Contract Test, Pact Testing

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

Think of it like

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

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.

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.
Both sides are tested against the shared contract file.

Common mistake

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

Key takeaways

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

Compare