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 |

Multiple rows, same topicโ€‹

Add multiple rows to validate several records in one step, sequentially, in order, as long as every row targets the same physical topic:

Then expected record from file
| topicAlias | file | expectedRecordKey | consumerReadTimeout | consumerDeltaTime |
| orders-out | expected-1.json | order-001 | 30 | 60 |
| orders-out | expected-2.json | order-002 | 30 | 60 |

All rows in the same step share one pinned referenceTimestamp ("now" captured once at the top of the step), so their consumerDeltaTime seek windows are computed identically instead of drifting row-to-row. Mixing topics in one DataTable throws TopicMismatchException before any consumer call is made. See Multi-row DataTables for the full rules, including why batch steps stay single-row.


See alsoโ€‹