This sample project demonstrates how we can run contract tests against a service which interacts with a kafka broker.
NOTE: This project uses AsyncAPI 2.6 specification. For equivalent sample project that uses AsyncAPI 3.0 spec please refer to specmatic-kafka-sample-asyncapi3.
This project includes a consumer that listens to messages on a specific topic. Upon receiving a message, the consumer processes it and publishes a new message to two other designated topics.
- Gradle
- JDK 17+
- Docker
./gradlew clean test
- Start the kafka broker using below command.
docker compose up
- Run the application.
./gradlew bootRun
- Run the contract tests.
docker run --network host -v "$PWD/specmatic.yaml:/usr/src/app/specmatic.yaml" -v "$PWD/src/test/resources:/usr/src/app/examples" -v "$PWD/build/reports:/usr/src/app/build/reports" znsio/specmatic-kafka-trial:0.22.13 test --examples=examples
- To get information around all the CLI args of the
virtualize
command, run the following.docker run znsio/specmatic-kafka-trial virtualize --help
- To get information around all the CLI args of the
test
command, run the following.docker run znsio/specmatic-kafka-trial test --help