Kafka jar does not include kafka.utils.testutils

I am trying to write a unit test test case for a kafka producer / consumer and came across a simple example http://grokbase.com/t/kafka/users/13ck94p302/writing-unit-tests-for-kafka-code .

p>

Using this code, I realized that the bank does not have the Testutils class. I started some research on how to enable this and find out that apache is not sending Testutils with the jar. I do not understand the reason. Then I found this https://issues.apache.org/jira/browse/KAFKA-1308 , which asks me to run some gradle commands.
I'm confused. Why do I need it? Is there an easier way to write this unit test or enable Testutils?

+4
source share
2 answers
<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.11</artifactId>
    <version>0.8.2.1</version>
    <classifier>test</classifier>
</dependency>
+8
source

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.

+2
source

All Articles