Quick Start
You need a dedicated Kafka environment for testing, a broker (and optionally a Schema Registry) that is not shared with any other team or application. Read CI environment โ if you haven't set one up yet.
1. Create your test repositoryโ
Your features and assets live in a dedicated Git repository, separate from your application code. This is your test project; your CI pipeline checks it out to run KTestify.
Inside that repository, each feature set gets its own folder with its assets right next to it:
my-ktestify-tests/ โ Git repository root
โโโ workspace/
โโโ features/
โโโ order-processing/
โโโ order-processing.feature
โโโ assets/
โโโ order.json โ input payload (sent to Kafka)
โโโ order-enriched.json โ expected output (asserted from Kafka)
Your CI pipeline checks out this repository and mounts workspace/ into the container at /workspace.
2. Write your payloadsโ
workspace/features/order-processing/assets/order.json
{
"orderId": "order-001",
"product": "Widget A",
"quantity": 3
}
workspace/features/order-processing/assets/order-enriched.json
{
"orderId": "order-001",
"product": "Widget A",
"quantity": 3,
"status": "PROCESSED"
}
3. Write the feature fileโ
workspace/features/order-processing/order-processing.feature
Feature: Order processing pipeline
Background:
Given namespace
| namespace |
| myapp |
Given input topic
| topicName | topicAlias |
| orders-in | orders-in |
Given output topic
| topicName | topicAlias |
| orders-out | orders-out |
Given assets directory
| absolutePath |
| /workspace/features/order-processing/assets |
Scenario: Order is enriched with PROCESSED status
When record from file is sent
| topicName | file | recordKey |
| orders-in | order.json | order-001 |
Then expected record from file
| topicAlias | file | expectedRecordKey |
| orders-out | order-enriched.json | order-001 |
4. Run KTestifyโ
Clone your test repository, then run the container with the workspace mounted:
# From the root of your test repository (my-ktestify-tests/)
docker run --rm \
-v "$(pwd)/workspace/features:/workspace/features" \
-v "$(pwd)/workspace/reports:/workspace/reports" \
-e KTESTIFY_BOOTSTRAP_SERVERS=kafka:9092 \
-e KTESTIFY_TOPIC_NAMESPACE=myapp \
ghcr.io/ktestify/ktestify-cucumber:latest \
/workspace/features
KTestify will:
- Send
order.jsonto topicmyapp.orders-inwith keyorder-001 - Wait for a matching record on
myapp.orders-out - Compare it against
order-enriched.json - Exit
0if the assertion passes, non-zero otherwise
Next stepsโ
- Step reference โ, every step and every DataTable column
- โ๏ธ Configuration โ, HOCON keys and environment variable overrides
- Dynamic variables โ, inject dates, UUIDs, env vars into payloads
- โ ๏ธ CI environment โ, scheduling daily regression tests