Verify
Fluent assertions
Three flavours of assertion — for one record you already consumed, for the topic as a whole, and for collection-style queries over many records.
Overview
The assertion pages collect the fluent checks for Kafka records and topics. Use them when you want the test to read like the event contract instead of a chain of low-level polling and object comparisons.
Record assertions
Assert keys, values, headers, metadata, JsonPath expressions, and reusable payload matchers on a consumed ConsumerRecord.
Topic assertions
Assert topic contents, listener readiness, ordered snapshots, and multi-topic choreography.
Extraction assertions
Extract keys, values, or JsonPath fields from many records and assert over the collection.
Starting points
Use KafkaAssertions.assertThat(record) when your test has already consumed a record:
assertThat(record)
.hasKey("order-123")
.hasJsonPath("$.status", "CREATED");Use KafkaAssertions.assertThatRecord(...) when you want the assertion API to read one record from the shared broker:
assertThatRecord("orders-topic", OrderEvent.class)
.hasJsonPath("$.customer.id", "cust-42");Use KafkaAssertions.assertThatTopic(...) when the topic contents are the subject of the test:
assertThatTopic("orders-topic")
.hasReadyListeners("orderListener")
.records(OrderEvent.class)
.inOrder()
.containingExactly(
r -> r.hasJsonPath("$.status", "CREATED"));