I am trying to write a unit test test case for kafka producer/consumer and came across a simple example http://grokbase.com/t/kafka/users/13ck94p302/writing-unit-tests-for-kafka-code.
On using this code I figured the jar does not have Testutils class. I started some research on how to include this and find out that apache doesnot ship Testutils with the jar.
I do not understand the reason. Then found this https://issues.apache.org/jira/browse/KAFKA-1308 which asks me to run some gradle commands.
I am confused. Why do I need to do that? Is there a simpler way to write this unit test or include Testutils ?
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.8.2.1</version>
<classifier>test</classifier>
</dependency>
In general, you don't include test utilities in the main production jar. This pollutes the main code with test code which is unnecessary and bloats the most frequently used jar.
Try to find a separate kafka test jar or dependency and include that in your build system and you should be able to use the TestUtils 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