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✅noneAlias of a declared output topic
filestring✅noneExpected file path, relative to assets directory
expectedRecordKeystring❌noneFilter: 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​