Skip to content

Contract test

A test of agreed messages between a consumer and a provider at an application interface.

Software quality

Check the shared interface expectation

A contract test checks whether messages between applications conform to the agreed interface contract. Consumer and provider can be tested separately. Consumer-driven contracts capture interactions actually needed and verify them against the provider too.

In a fictional example, a report view needs orderId and status from a job response. The test checks the agreed response for this case; relevant error cases belong in it when the consumer relies on them. A simulated provider alone, without verification against the provider, does not confirm the real interface. A contract test also proves neither correct job storage nor effective access isolation nor the complete user workflow. Complementary checks are needed for those.

Sources