Contract testing
Contract testing is a software testing technique that checks whether interacting components conform to an agreed interface 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 →
Microservices Patterns, Second Edition
Testing that verifies services and their clients or collaborators conform to agreed interaction contracts without requiring them to be tested together.
- How it is used
- Supports independently deployable services by checking interaction compatibility without testing services together.
- How deep it goes
- Explains provider and client checks and the consumer-provided contract workflow, while deferring detailed testing patterns.
- Examples
- Uses an Order Service and Consumer Service interaction and a field removal that passes all client contracts.
- What you can do after
- Practice consumer-driven contract testing by supplying client contracts and incorporating them into the provider’s automated checks.
Read how Microservices Patterns, Second Edition 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 →
Grokking Software Architecture
An individual test that verifies a component conforms to an agreed behavioral contract.
- How it is used
- Tests whether subclasses honor a parent class’s behavioral promises, exposing violations of the Liskov Substitution Principle.
- How deep it goes
- Explains how to reuse parent-class unit tests across subclasses, without detailing a separate test framework or setup.
- Examples
- Uses Player tests for moving away from the net to check Goalie and Midfielder behavior.
- What you can do after
- Diagnose substitution failures by running parent-class behavior tests against subclasses.
Read how Grokking Software Architecture explains contract testing →
Vibe Engineering
A testing technique in which a service consumer's expected requests and responses are checked against a service provider's actual behavior.
- How it is used
- Stabilizes APIs between service consumers and providers, especially when AI-generated changes may alter established behavior.
- How deep it goes
- Explains consumer-provider expectations through a worked request-response example and identifies breaking changes, without detailing test implementation.
- Examples
- Uses a content management system, rendering service, markup request, and expected HTML response.
- What you can do after
- Apply it via Pact-style contracts to detect incompatible provider changes before dependent services silently break.
Also covered in
- Write Powerful Rust Macros
- The Art of Code
- Platform Engineering on Kubernetes
- Automating API Delivery
- gRPC Microservices in Go
What to know first
- end-to-end testingEnd-to-end testing evaluates a complete system workflow across integrated components, from an external entry point to its observable outcome.
- contractA contract is an agreed specification of the conditions, expectations, rights, or obligations that govern behavior or interactions between parties or software components.
- integration testAn integration test evaluates whether multiple software components, or a component and an external dependency, interact and behave correctly together.
- OpenAPI specificationThe OpenAPI Specification is a machine-readable standard for describing HTTP APIs, including their operations, inputs, outputs, data structures, and security requirements.
Related concepts
- Pactincludes · Pact is an open-source contract-testing toolset that verifies interactions between service consumers and providers against consumer-defined expectations.
- 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.
- contractuses · A contract is an agreed specification of the conditions, expectations, rights, or obligations that govern behavior or interactions between parties or software components.
- consumer contractuses · A consumer contract is a machine-readable agreement specifying the interactions and responses a consumer expects from a service provider.
- integration testkind of · An integration test evaluates whether multiple software components, or a component and an external dependency, interact and behave correctly together.
- software testingcontrasts with · Software testing is the systematic evaluation of software under specified inputs or conditions to assess its behavior against expected results or requirements and identify defects.
Questions about contract testing
What is contract testing?
Contract testing is a software testing technique that checks whether interacting components conform to an agreed interface or behavioral contract.
Which Manning books explain contract testing?
Contract Testing in Action, Microservices Patterns, Second Edition, Secure APIs, Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform, Effective Platform Engineering, Grokking Software Architecture and Vibe Engineering.
What should I know before learning contract testing?
Manning books that teach contract testing usually introduce end-to-end testing, contract, integration test and OpenAPI specification first.
What is the difference between contract testing and provider-driven contract testing?
Contract testing is a software testing technique that checks whether interacting components conform to an agreed interface or behavioral contract. 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.
What kinds of contract testing are there?
Kinds of contract testing include Pact.
What is contract testing a kind of?
Contract testing is a kind of integration test. An integration test evaluates whether multiple software components, or a component and an external dependency, interact and behave correctly together.
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.






