beginner~2h

Testing the Producer

A Kafka producer with no tests is a producer you can't safely refactor. This module covers the three layers of testing used throughout the reference app.

Learning objectives

  • Beginner: Distinguish a unit test from an integration test for a Kafka producer.
  • Intermediate: Unit-test a producer's REST endpoint and its Kafka-sending logic by mocking KafkaTemplate.
  • Advanced: Write an Embedded Kafka integration test that proves a real message was actually produced to a real (in-process) broker.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.

Testing the Producer

Next Step

Continue to API Documentation with OpenAPI / Swagger← Back to all Kafka & Microservices chapters