Avro Assertions
Avro matchers deserialise GenericRecord values (via Schema Registry) and compare them as JSON or by individual fields.
File match : Then expected record from file based on schemaโ
Fetches an Avro record, converts it to JSON, and compares it against an expected JSON file. Excludes specified top-level keys from comparison.
Then expected record from file based on schema
| topicAlias | file | excludedKeys | consumerReadTimeout |
| orders-out | expected.json | createdAt,eventId | 30 |
| Column | Type | Required | Description |
|---|---|---|---|
topicAlias | string | โ | Alias of a declared output topic |
file | string | โ | Expected JSON file path, relative to assets directory |
excludedKeys | string | โ | Comma-separated list of Avro field names to ignore during comparison |
expectedRecordKey | string | โ | Filter: only accept records with this exact key |
consumerReadTimeout | integer | โ | Max seconds to wait for a record |
consumerDeltaTime | integer | โ | How far back (seconds) to seek |
Key + file match : Then expected record with key and value from file based on schemaโ
Asserts both the record key and value (as Avro โ JSON) against a file.
Then expected record with key and value from file based on schema
| topicAlias | file | excludedKeys |
| orders-out | expected.json | timestamp |
Field value match : Then expected record based on schema should have fields matching from given valueโ
Asserts one or more specific Avro field values without a file.
Then expected record based on schema should have fields matching from given value
| topicAlias | key | value |
| orders-out | status | PROCESSED |
| Column | Type | Required | Description |
|---|---|---|---|
topicAlias | string | โ | Alias of a declared output topic |
key | string | โ | Avro field name |
value | string | โ | Expected field value (string-compared after JSON serialisation) |
Key match : Then expected Avro record should match keyโ
Asserts only the record key; the Avro value is ignored.
Then expected record based on schema should match key
| topicAlias | expectedRecordKey |
| orders-out | ord-001 |
Positional fields : Then expected record based on schema should have fields matching from fileโ
Assert a specific character range of the JSON-serialised Avro value.
Then expected record based on schema should have fields matching from file
| topicAlias | file | line | from | to |
| orders-out | expected.txt | 1 | 0 | 10 |