Working examples that demonstrate how to use Contracteer for contract testing with OpenAPI specifications.
For concepts, getting started guides, and troubleshooting, see the Contracteer documentation.
All examples share a single OpenAPI specification (musketeer-spec) as the source of truth.
| I want to... | Contracteer module | Example |
|---|---|---|
| Verify my server matches the spec | contracteer-verifier-junit |
Spring Boot |
| Test my client with a mock server | contracteer-mockserver-spring |
Spring Boot |
contracteer-mockserver |
Plain Java (JUnit 5) |
contracteer-verifier-junit is framework-agnostic -- it
works with any server that can be started in a JUnit 5
test. The Spring Boot example is just one implementation.
contracteer-examples/
musketeer-spec/ OpenAPI specification (shared)
musketeer-spring-boot-server/ Server verified with contracteer-verifier-junit
musketeer-spring-boot-client/ Client tested with contracteer-mockserver (Spring Boot)
java-musketeer-client/ Client tested with contracteer-mockserver (plain Java)
- Java 21
- Contracteer available (from Maven Central or Maven Local)
Each project is a standalone Gradle project with its own
gradlew wrapper. Before running any project, publish the
shared specification:
cd musketeer-spec
./gradlew publishToMavenLocalThen follow the instructions in each project's README.
These examples are licensed under the Apache License 2.0.