liveBook · Manning

TestOutputTopic

As explained in Kafka for Architects

TestOutputTopic is a Kafka Streams testing class that reads and verifies records emitted by a topology under test.

TestOutputTopic is a Kafka Streams test topic used to inspect and verify records emitted by a topology under test. It complements TestInputTopic: test code supplies serialized records to input topics, then reads deserialized results from output topics without running a Kafka cluster. section 10.3.1

Use TestOutputTopic when the test must validate the topology’s Kafka-facing behavior rather than only isolated business logic:

  • Configure it with the output topic name and the serializers or deserializers for keys and values. section 10.3.1
  • Read and verify records produced after input records pass through stateless or stateful processing nodes. section 10.3.1
  • Use it with TopologyTestDriver to test complete topology behavior, while recognizing that real broker communication belongs in integration tests. section 10.3.1

Topology-level verification

A test pipes records into a TestInputTopic, runs the topology through its processing nodes, and inspects the corresponding TestOutputTopic to confirm the emitted records. Because serialization and deserialization occur as they do for Kafka messages, the test checks more than a direct method return value or a mocked producer call. section 10.3.1

How Kafka for Architects covers it

How deep it goes
Explains topic configuration and serialized output verification, while deferring real broker communication to integration tests.
Examples
Uses input records, serialized Kafka-like messages, emitted output records, and stateful stream-processing tests.
What it assumes
Assumes Kafka Streams topology and serialization knowledge while contrasting topology tests with mocked component unit tests.
What you can do after
Evaluate/understand topology behavior by supplying test records and verifying serialized output without a Kafka cluster.
How it connects
Connects Kafka Streams topologies with TopologyTestDriver, TestInputTopic, serialization, stateful processing, and integration testing.

Also explained in

Compare how 2 books explain TestOutputTopic →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.