Skip to main content

Contract Tests vs WireMock Stubs

Contract Tests vs WireMock Stubs

Updated 1 min readMarkdown

Short answer: Stubs are a code-level description of the responses; contract tests verify the responses against the schema. The first tells the mock what to return; the second proves the real response is valid. They are different stages and both belong in a pipeline.

What stubs provide

Controlled responses for the tests, so the system can be exercised without the real service. They are authored and can drift.

What contract tests provide

Property Stubs Contract tests
Subject Mock responses Real responses
Authority Stub code Schema
Catches drift Not directly Yes
Stage Isolation Verification

Why the stages matter

A stub lets the system run without the dependency; a contract test proves the dependency still conforms. Replacing one with the other leaves a gap.

The honest takeaway

Keep the stubs for isolation and the contract checks for conformance. A spec-first studio keeps both tied to the same source.

This is part of the Powerduck vs WireMock comparison. Next, read beyond JVM mocking.

No comments yet. Be the first to comment.

More from this blog