Glossary/Contract Testing
Testing & QA
1 min read
Share:

What is Contract Testing?

TL;DR

Contract testing verifies that the interactions between service providers and consumers conform to a shared contract (API specification).

Contract testing verifies that the interactions between service providers and consumers conform to a shared contract (API specification). Instead of testing the full integration, contract tests verify the interface agreement — what data shapes, status codes, and behaviors each side expects.

Tools: Pact (consumer-driven contract testing), Spring Cloud Contract (provider-side contracts), and OpenAPI-based contract testing. Pact workflow: 1) Consumer writes a test defining expected API behavior, 2) Pact generates a contract file, 3) Provider verifies it can satisfy the contract, 4) Both sides run independently.

Contract testing bridges the gap between unit tests (too isolated) and integration tests (too coupled). It enables independent service deployment — teams can deploy without coordinating with every consumer.

Why It Matters

In microservices, the most dangerous bugs are contract violations — a provider changes a response field and breaks 10 consumers. Contract testing catches these before deployment, enabling independent team velocity.

Frequently Asked Questions

What is contract testing?

Testing that verifies service interactions conform to a shared API contract. Catches interface changes (field renamed, type changed) before deployment. Bridges gap between unit and integration tests.

Contract testing vs integration testing?

Integration tests run services together (coupled, slow). Contract tests verify the interface agreement independently (decoupled, fast). Contract testing enables independent deployment; integration testing doesn't.

Related Terms

Need Expert Help?

Richard Ewing is a Product Economist and AI Capital Auditor. He helps companies translate technical complexity into financial clarity.

Book Advisory Call →