Raw Record Assertions
Raw matchers compare String-serialised Kafka record values against an expected file or positional field range. These steps apply to topics declared as raw (non-Avro).
File match : Then expected record from fileโ
Fetches the next record from the output topic and asserts its value matches the content of an expected file character-for-character (with coloured diff on failure).
Then expected record from file
| topicAlias | file | expectedRecordKey | consumerReadTimeout | consumerDeltaTime |
| orders-out | expected.json | order-001 | 30 | 60 |
| Column | Type | Required | Default | Description |
|---|---|---|---|---|
topicAlias | string | โ | โ | Alias of a declared output topic |
file | string | โ | โ | Expected file path, relative to assets directory |
expectedRecordKey | string | โ | โ | Filter: only accept records with this exact key |
consumerReadTimeout | integer | โ | From config (30s) | Max seconds to wait for a record |
consumerDeltaTime | integer | โ | From config (60s) | How far back (seconds) to seek before consuming |
Key + value match : Then expected record with key and value from fileโ
Asserts both the record key and value match the content of an expected file.
Then expected record with key and value from file
| topicAlias | file | consumerReadTimeout |
| orders-out | expected.json | 30 |
The expected file must contain the key on the first line and the value starting from the second line (same format as FileKeyRecordMatcher).
Positional fields : Then expected record should have fields matching from fileโ
Asserts a specific character range within a specific line of the record value.
Then expected record should have fields matching from file
| topicAlias | file | line | from | to |
| orders-out | expected.txt | 2 | 0 | 15 |
| Column | Type | Required | Description |
|---|---|---|---|
topicAlias | string | โ | Alias of a declared output topic |
file | string | โ | Expected file path |
line | integer | โ | 1-based line number in the record value |
from | integer | โ | Start character index (inclusive) |
to | integer | โ | End character index (exclusive) |
Record key match : Then expected record should match keyโ
Asserts only the record key (value is ignored).
Then expected record should match key
| topicAlias | expectedRecordKey | consumerReadTimeout |
| orders-out | order-001 | 30 |