In general, you do not include test utilities in the main jar. This pollutes the main code with a test code that is not needed and inflates the most commonly used jar.
Try to find a separate test jar or dependence on kafka and include it in your build system, and you can use the TestUtils class.
source
share