liveBook · Manning

Integration test

As explained in Kafka Streams in Action, Second Edition

Integration testing verifies interactions and behavior among multiple software components and their dependencies.

An integration test checks that multiple application components and their external dependencies interact correctly. Unlike a unit test, it uses the real dependencies rather than mocks, trading subsecond execution for broader, slower validation. section 14.1

For Kafka Streams, the test runs a live Kafka broker, starts the topology, produces timestamped records, consumes output, and compares the results with an expected sequence. This verifies the assembled application rather than one operator in isolation. section 14.1.5

A practical integration-test workflow includes:

  • Start and manage a Kafka broker in a Docker container with Testcontainers and JUnit 5. section 14.1.5
  • Configure Kafka Streams, producers, and consumers with the container's bootstrap server. section 14.1.5
  • Start the topology, wait until Kafka Streams reaches the RUNNING state, and feed it test records. section 14.1.5
  • Clean up topics after each test while reusing a static container when appropriate to reduce startup cost. section 14.1.5

Testing a hopping-window count

A JUnit 5 test sends six groups of records for the key "Foo" at timestamp intervals, reads the output topic, and asserts counts that rise from 1 through 21 before declining as records leave the hopping window. section 14.1.5

Table 14.1 Unit testing compared to integration testing
Type
Purpose
Speed
Percentage of use
Unit
Method level, finer-grained logic, objects in isolation
Subsecond
Majority
Integration
Holistic, integrated components, course grained
Seconds to minutes
Minority

Compare integration tests with unit tests by purpose, execution speed, granularity, and typical share of the test suite. section 14.1

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains real-dependency execution, container lifecycle, stream startup, stateful caching, timestamped input, output consumption, and teardown.
Examples
Uses a Kafka Streams hopping-window count with timestamped records, a live broker, producer input, consumer output, and expected count assertions.
What it assumes
Assumes familiarity with Docker, Kafka producers and consumers, Kafka Streams topologies, and JUnit 5 test structure.
What you can do after
Build integration tests with JUnit 5 and Testcontainers that exercise a Kafka Streams topology against a live Kafka broker.
How it connects
Connects integration testing with unit testing, mocking, Kafka Streams, JUnit 5, Testcontainers, Docker, and continuous integration.

Also explained in

Compare how 31 books explain integration test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.