Home

ContractTesting

Contract testing is a software testing approach focused on the interactions between services, particularly the agreements or contracts that define how a consumer talks to a provider. A contract specifies the expected requests, responses, and behavior for a given integration, and serves as a behavioral guarantee between teams that own the consumer and the provider.

The core idea is to separate contract verification from broader integration tests. In a typical consumer-driven

Two common approaches exist: consumer-driven contract testing, where consumers define and publish contracts for providers to

Benefits include faster feedback, better isolation of teams, and reduced flaky integration tests by catching incompatibilities

contract
testing
pattern,
the
consumer
writes
tests
that
express
its
expectations
and
generates
a
contract.
This
contract
is
published
to
a
central
repository
or
broker
and
used
by
the
provider
to
verify
that
it
can
fulfill
the
contract.
If
the
provider
changes
its
API
in
a
way
that
violates
the
contract,
the
verification
fails,
prompting
a
discussion
or
rollback
before
the
change
reaches
production.
honor,
and
provider-driven
contracts,
where
providers
declare
their
API
expectations
for
consumers
to
implement
against.
Tools
in
this
space
include
Pact
(with
multiple
language
bindings
and
broker
services),
Spring
Cloud
Contract,
and
Hoverfly,
among
others.
early.
Limitations
involve
ensuring
contract
completeness,
handling
dynamic
or
evolving
data,
and
the
need
for
governance
to
prevent
drift.
Contract
testing
is
often
used
in
microservice
architectures
and
API
integrations,
complementing
but
not
replacing
end-to-end
tests.