Contract testing
Contract testing is a software testing technique that verifies whether interacting components conform to an agreed interface, message, or behavioral contract.
Contract Testing in Action
A software testing technique that verifies compatibility between a service provider and its consumers through an agreed contract of requests and responses.
- How it is used
- Protects connected systems from incompatible request and response changes before deployment, especially across microservices.
- How deep it goes
- Explains consumer contract generation and provider verification workflows, while deferring detailed implementation and storage approaches.
- Examples
- Uses a User API, web and mobile consumers, renamed fullName fields, mock providers, shared brokers, and GraphQL services.
- What you can do after
- Apply it via Pact to generate consumer contracts, verify providers, publish results, and gate compatible deployments.
Read how Contract Testing in Action explains contract testing →
Secure APIs
Contract testing is a testing approach that verifies an API implementation conforms to an agreed API contract or specification.
- How it is used
- Uses an API specification to verify that server behavior remains compliant and to detect drift during security testing.
- How deep it goes
- Explains drift, generated fuzz cases, checks, and security findings, but stops short of business-layer coverage.
- Examples
- Uses orphan endpoints, undocumented parameters, pagination limits, Schemathesis commands, and malformed payload failures as concrete examples.
- What you can do after
- Diagnose API drift and implementation weaknesses by running Schemathesis checks against an OpenAPI specification.
Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform
A contract test verifies that an integration between components conforms to an agreed interface or behavioral contract.
- How it is used
- Enforces agreements between infrastructure modules so dependency changes do not silently break downstream configuration.
- How deep it goes
- Defines static input-output comparison, demonstrates assertions, and places tests in a release workflow without detailing runtime behavior.
- Examples
- Uses a network facade, expected network name and CIDR range, pytest fixtures, and a database module consuming a network ID.
- What you can do after
- Diagnose dependency mismatches before deployment and preserve module integrations during changes or tool migrations.
Effective Platform Engineering
A contract test verifies that an implementation conforms to the interface or behavioral contract expected by its consumers.
- How it is used
- Protects reliability and trust as platform teams and consumers evolve independently.
- How deep it goes
- Defines platform-consumer boundaries and executable architectural checks, but stops short of a full contract-test implementation.
- Examples
- Uses platform-team boundaries, repository-datastore separation, layered API access, and cloud-specific API isolation.
- What you can do after
- Apply it via fitness functions to detect incorrect layer access and make platform evolution more predictable.
Read how Effective Platform Engineering explains contract testing →
Related concepts
- provider-driven contract testingalternative to · Provider-driven contract testing is a contract-testing workflow in which the provider determines or contributes the contract expectations and compares them with consumer expectations.
- Pactincludes · Pact is an open-source contract-testing toolset that verifies interactions between service consumers and providers against consumer-defined expectations.
- contractuses · An API contract is a specification of the operations, data, and behavioral expectations that govern interactions between software components.
- testcontrasts with · A test is a procedure or check that evaluates behavior using specified inputs or evidence against expected results or criteria.
- integration testkind of · An integration test evaluates whether multiple software components, or a component and an external dependency, interact and behave correctly together.
- consumer contractuses · A consumer contract is a machine-readable agreement specifying the interactions and responses a consumer expects from a service provider.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



