Table of Contents
This sample project demonstrates how Specmatic can be used to contract test an API in isolation before integrating with consumers.
The interaction between Order API in this project and it's consumers is governed by this OpenAPI specification..
- Spring Boot service written in Java
- Specmatic
- Docker Desktop (for running contract tests with containers)
Specmatic contract tests use the specmatic.yaml configuration file to start the required Specmatic stub before verifying the Order API.
For Unix based systems and Windows PowerShell:
./mvnw test -Dtest=ContractTestFor Windows Command Prompt:
mvnw.cmd test -Dtest=ContractTestAfter the tests complete, view the report at build/reports/specmatic/html/index.html.
For Unix based systems and Windows PowerShell:
./mvnw test -Dtest=ContractTestUsingTestContainerTestFor Windows Command Prompt:
mvnw.cmd test -Dtest=ContractTestUsingTestContainerTestFor Unix based systems and Windows PowerShell:
# Start the service
./mvnw spring-boot:run# Run the contract tests
docker run --rm --network host -v "$(pwd)/specmatic.yaml:/usr/src/app/specmatic.yaml" -v "$(pwd)/build/reports/specmatic:/usr/src/app/build/reports/specmatic" specmatic/specmatic test --port=8090For Windows Command Prompt:
# Start the service
mvnw.cmd spring-boot:run# Run the contract tests
docker run --rm --network host -v "%cd%/specmatic.yaml:/usr/src/app/specmatic.yaml" -v "%cd%/build/reports/specmatic:/usr/src/app/build/reports/specmatic" specmatic/specmatic test --port=8090