characterize-with-contracts

Reuses the roster/adapter machinery of contract-testing-roster and mocking-strategy-roster, but with the opposite intent: encode what the code ACTUALLY does, right now, to verify a refactor does not change behavior.

When to use

Entry contract

Exit contract

Invariants

Why this shape

A characterization test encodes the exact current behavior (status, shape, value) — a golden master — so a refactor is verified non-regressive. The contract, discovered or reconstructed, is the common language between old and new behavior.

« Consumer-driven contracts let the consumer specify what it needs from a provider. » — Newman, S., Building Microservices, 2nd ed., 2021.

Allowed customisation

See also