smallrye-reactive-messaging
smallrye-reactive-messaging copied to clipboard
Kafka Companion design makes tests dependent on each other
Current approach to Kafka Companion does not provide out of the box solution for running independent test cases on same Companion instance within same topic.
Imagine, that you write multiple test cases within one test class, each requiring an independent data set for particular topic put into Kafka. You run your first test case, all fine, it passes, as Companion holds only this cases' data set. Then you run second case, configure data set - and the test fails, as it sees not only data set from second test, but also from the first one, as it doesn't gets cleaned up.
This could be nailed by deleting and recreating topic after each test case or using different topic names within each test, but this adds boilerplate code to each test class, as well as it removes focus from writing tests to managing Kafka state.
I would like to discuss this, and I could implement the fix, once we come up with a solution design.
Thank you!
@Nidum thanks for reporting this! I tried to answer this issue in https://github.com/smallrye/smallrye-reactive-messaging/discussions/1852#discussioncomment-3466705
Closing this, #1822 and #1961 provide improvements to the Companion API.