Skip to main content

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 |
ColumnTypeRequiredDefaultDescription
topicAliasstringโœ…โ€”Alias of a declared output topic
filestringโœ…โ€”Expected file path, relative to assets directory
expectedRecordKeystringโŒโ€”Filter: only accept records with this exact key
consumerReadTimeoutintegerโŒFrom config (30s)Max seconds to wait for a record
consumerDeltaTimeintegerโŒ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 |
ColumnTypeRequiredDescription
topicAliasstringโœ…Alias of a declared output topic
filestringโœ…Expected file path
lineintegerโœ…1-based line number in the record value
fromintegerโœ…Start character index (inclusive)
tointegerโœ…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 |

See alsoโ€‹