I am writing a test class that has multiple methods that require Kafka. Each one requires different broker properties, so I want a separate instance of EmbeddedKafka for each. Doing
@EmbeddedKafka(
partitions = 20,
topics = {"topic"},
controlledShutdown = false,
brokerProperties = {
"listeners=PLAINTEXT://localhost:9091",
"port=9091",
"auto.create.topics.enable=false",
"delete.topic.enable=true"
})
Uses the broker properties for each method in the class. I don't want this. One way to overcome this would be to put each test method in a separate class with different broker properties. But I don't want to do this, as this would blow up the number of files I need.
Is there some way around this?
It's better to use different topics in each test. However, you can add @DirtiesContext to each test method or add @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) to the test class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With