Reputation: 2009
I have a Spring Kafka project, and I have written some unit tests for it. When I execute the test classes, the project attempts to use the actual Kafka broker, and not the embedded Kafka broker as annotated in my test class.
@RunWith(SpringRunner.class)
@SpringBootTest
@EmbeddedKafka
@DirtiesContext
public class SpringKafkaReceiverTest {...}
What I have attempted is checked into gitlab --> https://gitlab.com/mohammad.mnajar/spring-kafka-unit-test
Any help would be extremely appreciated.
Upvotes: 0
Views: 300
Reputation: 174484
See the documentation.
You need to set the spring.kafka.bootstrap-servers
property to the embedded kafka's getBrokersAsString()
.
Upvotes: 1