Files

contracts

Consumer-driven contract testing for a Spring Boot 4.2 service pair, done three ways against the same API: Spring Cloud Contract 5.0.3, Stubborn Contract 0.2.4 (its continuation) and Pact JVM 4.7.7. Companion to the ankurm.com post Consumer-Driven Contract Testing: Spring Cloud Contract vs Pact for Spring Boot.

Module Role
orders-producer/ Boot app serving GET /orders/{id} and POST /orders. Holds the YAML contracts, the base class for the generated tests, and the Pact provider verification. Publishes orders-producer-1.0.0-stubs.jar
checkout-consumer/ Boot app with a RestClient based OrderClient. Has a Pact consumer test (writes the pact) and a stub runner test (uses the producer's stubs)

pom-stubborn.xml in each module is the same build with Stubborn Contract coordinates (sh.stubborn:*); the contracts and sources are untouched.

Versions

JDK Temurin 25.0.5.1 (LTS)
Spring Boot 4.2.0
Spring Cloud Contract 5.0.3 (last release; it is no longer in the Spring Cloud 2026.0.0 BOM)
Stubborn Contract 0.2.4
Pact JVM 4.7.7 (consumer:junit5, provider:junit5)
REST Assured 7.0.0 (overrides the 5.5.7 that Spring Cloud Contract 5.0.3 brings)
WireMock 3.13.2

Run it

export JAVA_HOME=<jdk-25>
./scripts/run-all.sh          # about 5 minutes, regenerates everything in output/

Or by hand, in this order (the pact has to exist before the producer verifies it, the stubs before the consumer uses them):

(cd checkout-consumer && mvn clean test -Dtest=OrdersPactConsumerTest)
mkdir -p orders-producer/src/test/resources/pacts
cp checkout-consumer/target/pacts/*.json orders-producer/src/test/resources/pacts/
(cd orders-producer && mvn clean install)                       # generated tests + pact verification + stubs jar
(cd checkout-consumer && mvn clean test -Dtest=OrdersStubConsumerTest)

Simulate a producer change with an environment variable (read as orders.variant):

ORDERS_VARIANT=rename-total mvn clean test      # baseline | add-field | rename-total | drop-items | total-string

Always use clean after editing a contract: Spring Cloud Contract skips generation when it thinks the generated sources are up to date.

Output

Every file in output/ comes from a real run of scripts/run-all.sh, filtered by scripts/clean.py (launcher noise, Spring Boot banners, stack frames and WireMock request dumps removed; nothing retyped). Timings are replaced by N.

File What it shows
01-versions.txt JDK, Maven and the resolved contract libraries
02-consumer-pact-run.txt, 03-pact-file.json the consumer test run and the pact it wrote
04-producer-baseline.txt contract test generation, generated tests green, pact verified, stubs jar built
05-generated-test.txt the JUnit class Spring Cloud Contract generated from the YAML
06-stubs-jar.txt, 07-wiremock-mapping.json what is inside the stubs jar
08-consumer-stub-run.txt the consumer against the producer's stubs
10..13-variant-*.txt four producer changes, each run through both tools
20-restassured-5-groovy-5.txt the REST Assured 5.5.7 / Groovy 5.1.3 failure
21, 22 producer renames a field in its contract and republishes; consumer meets the new stubs
30, 31 the same contracts under Stubborn Contract 0.2.4