Mocked Streams 3.6.0 is a library for Scala 2.12 and Scala 2.13 which allows you to unit-test processing topologies of Kafka Streams applications (since Apache Kafka >=0.10.1) without Zookeeper and Kafka Brokers. Further, you can use your favourite Scala testing framework e.g. ScalaTest and Specs2. Mocked Streams is located at the Maven Central Repository, therefore you just have to add the following to your SBT dependencies:
libraryDependencies += "com.madewithtea" %% "mockedstreams" % "3.6.0" % "test"
Getting Started
It wraps the org.apache.kafka.streams.TopologyTestDriver class, but adds more syntactic sugar to keep your test code simple:
import com.madewithtea.mockedstreams.MockedStreams
val input = Seq(("x", "v1"), ("y", "v2"))
val exp = Seq(("x", "V1"), ("y", "V2"))
val strings = Serdes.String()
MockedStreams()
.topology { builder => builder.stream(...) [...] } // Scala DSL
.input("topic-in", strings, strings, input)
.output("topic-out", strings, strings) shouldEqual exp
Apache Kafka Compatibility
Please use the corresponding Mocked Streams version to a concrete Apache Kafka version.
Mocked Streams Version | Apache Kafka Version |
---|---|
3.6.0 | 2.4.1.0 |
3.5.2 | 2.4.0.0 |
3.5.1 | 2.4.0.0 |
3.5.0 | 2.4.0.0 |
3.4.0 | 2.3.0.0 |
3.3.0 | 2.2.0.0 |
3.2.0 | 2.1.1.0 |
3.1.0 | 2.1.0.0 |
2.2.0 | 2.1.0.0 |
2.1.0 | 2.0.0.0 |
2.0.0 | 2.0.0.0 |
1.8.0 | 1.1.1.0 |
1.7.0 | 1.1.0.0 |
1.6.0 | 1.0.1.0 |
1.5.0 | 1.0.0.0 |
1.4.0 | 0.11.0.1 |
1.3.0 | 0.11.0.0 |
1.2.1 | 0.10.2.1 |
1.2.0 | 0.10.2.0 |
1.1.0 | 0.10.1.1 |
1.0.0 | 0.10.1.0 |