Skip to content

Testkit

Simon Souter edited this page Dec 6, 2018 · 23 revisions

Supports integration testing of Kafka client code by providing helpers that can start an in-process Kafka and Zookeeper server.

Resolve

Artifacts are published to bintray here: Bintray Repo To resolve using sbt, add the following resolver to your build.sbt:

resolvers += Resolver.bintrayRepo("cakesolutions", "maven")

And add the dependency:

// Latest release for Kafka 2.1.0:
libraryDependencies += "net.cakesolutions" %% "scala-kafka-client-testkit" % "2.1.0"

// Latest release for Kafka 2.0.0:
libraryDependencies += "net.cakesolutions" %% "scala-kafka-client-testkit" % "2.0.0"

// Latest release for Kafka 1.1.1:
libraryDependencies += "net.cakesolutions" %% "scala-kafka-client-testkit" % "1.1.1"

// Latest release for Kafka 0.11.0.0:
libraryDependencies += "net.cakesolutions" %% "scala-kafka-client-testkit" % "0.11.0.0"

// Latest release for Kafka 0.10.x.x:
libraryDependencies += "net.cakesolutions" %% "scala-kafka-client-testkit" % "0.10.2.2"

Logging dependency

The testkit has a dependency on Kafka, but excludes it's transitive dependency on log4j, the logging library used by Kafka. To avoid getting a NoClassDefFoundError: org/apache/log4j/Logger, one of the following should be added to the libraryDependencies:

  • If using SLF4J:

libraryDependencies += "org.slf4j" % "log4j-over-slf4j" % "1.7.21" % "Test",

  • If using Log4j:

libraryDependencies += "log4j" % "log4j" % "1.2.14" % "Test"