Are there any ways to write integration tests for Reactive Kafka in Spring?

Viewed 16

I need to write integration tests and mock reactive Kafka consumer. I see there're ways to do it with blocking Kafka, like using @EmbeddedKafka but was not able to find information about reactive

1 Answers

As linked in the comments, reactor-kafka project themselves use TestContainers for integration tests. If you don't run tests in an environment with Docker, then spring-kafka-test's EmbeddedKafka, or junit-kafka project should still work with Reactive-based Kafka clients since you really only need bootstrap.servers property to point at any valid broker server.

Regarding mocks, you don't need an actual broker; that's the point of mocking. Their source code does include mock classes, too.

Related