You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# scalatest-embedded-kafka
2
-
A library that provides an in-memory Kafka broker to run your ScalaTest specs against.
2
+
A library that provides an in-memory Kafka instance to run your tests against.
3
+
4
+
*As of version 1.1.1 the library is not dependent anymore on ScalaTest and won't transitively ScalaTest into your build*
3
5
4
6
Inspired by https://github.com/chbatey/kafka-unit
5
7
@@ -14,22 +16,22 @@ Inspired by https://github.com/chbatey/kafka-unit
14
16
15
17
### Version compatibility matrix
16
18
17
-
scalatest-embedded-kafka is available on Bintray and Maven Central, compiled for both Scala 2.11 and 2.12.
19
+
scalatest-embedded-kafka is available on Bintray and Maven Central, compiled for both Scala 2.11 and 2.12. Scala 2.10 is supported until `0.10.0`. Scala 2.12 is supported from `0.11.0` onwards, following Apache Kafka release cycle.
18
20
19
-
* Scala 2.10 is supported until `0.10.0`
20
-
* Scala 2.11 is supported for all versions
21
-
* Scala 2.12 is supported from `0.11.0`.
21
+
Currently there's no support for Scala 2.13-Mx as Kafka artifacts are not published for these versions.
22
22
23
-
Starting from 1.0.0, versions match the version of Kafka they're built against.
23
+
Starting from 1.0.0, versions match the version of Kafka they're built against. However in the past there were some mismatches - the easiest way is to check through the git history of the `build.sbt` file
24
24
25
25
*If you're using Kafka 1.1.0, please use version `1.1.0-kafka1.1-nosr` - this version doesn't pull in the Confluent Schema Registry by default*
26
26
27
27
### How to use
28
28
29
-
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-kafka" % "1.1.0-kafka1.1-nosr" % "test"`
30
-
* Have your `Spec` extend the `EmbeddedKafka` trait.
29
+
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-kafka" % "1.1.1" % "test"`
30
+
* Have your class extend the `EmbeddedKafka` trait.
31
31
* Enclose the code that needs a running instance of Kafka within the `withRunningKafka` closure.
32
32
33
+
An example, using ScalaTest:
34
+
33
35
```scala
34
36
classMySpecextendsWordSpecwithEmbeddedKafka {
35
37
@@ -49,7 +51,8 @@ class MySpec extends WordSpec with EmbeddedKafka {
49
51
50
52
### Use without the `withRunningKafka` method
51
53
52
-
A `EmbeddedKafka` companion object is provided for usage without the `EmbeddedKafka` trait. Zookeeper and Kafka can be started and stopped in a programmatic way.
54
+
A `EmbeddedKafka` companion object is provided for usage without extending the `EmbeddedKafka` trait. Zookeeper and Kafka can be started and stopped in a programmatic way. This is the recommended usage if you have more than one test in your file and you don't want to start and stop Kafka and Zookeeper on every test.
A library that builds on top of `scalatest-embedded-kafka` to offer easy testing of [Kafka Streams](https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Streams) with ScalaTest.
200
+
A library that builds on top of `scalatest-embedded-kafka` to offer easy testing of [Kafka Streams](https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Streams).
198
201
199
202
It takes care of instantiating and starting your streams as well as closing them after running your test-case code.
200
203
201
204
### How to use
202
205
203
-
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-kafka-streams" % "1.1.0-kafka1.1-nosr" % "test"`
206
+
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-kafka-streams" % "1.1.1" % "test"`
204
207
* Have a look at the [example test](kafka-streams/src/test/scala/net/manub/embeddedkafka/streams/ExampleKafkaStreamsSpec.scala)
205
208
* For most of the cases have your `Spec` extend the `EmbeddedKafkaStreamsAllInOne` trait. This offers both streams management and easy creation of consumers for asserting resulting messages in output/sink topics.
206
209
* If you only want to use the streams management without the test consumers just have the `Spec` extend the `EmbeddedKafkaStreams` trait.
@@ -247,8 +250,8 @@ If you need to serialize and deserialize messages using Avro, a [Confluent Schem
247
250
### How to use
248
251
249
252
* In your `build.sbt` file add the following resolver: `resolvers += "confluent" at "https://packages.confluent.io/maven/"`
250
-
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-schema-registry" % "1.1.0-kafka1.1-nosr" % "test"`
251
-
* Have your `Spec` extend the `EmbeddedKafkaWithSchemaRegistry` trait.
253
+
* In your `build.sbt` file add the following dependency: `"net.manub" %% "scalatest-embedded-schema-registry" % "1.1.1" % "test"`
254
+
* Have your test extend the `EmbeddedKafkaWithSchemaRegistry` trait.
252
255
* Enclose the code that needs a running instance of Kafka within the `withRunningKafka` closure.
253
256
* Provide an implicit `EmbeddedKafkaConfigWithSchemaRegistryImpl`.
254
257
@@ -274,7 +277,7 @@ class MySpec extends WordSpec with EmbeddedKafkaWithSchemaRegistry {
274
277
275
278
The `net.manub.embeddedkafka.avro.schemaregistry` package object provides useful implicit converters for testing with Avro and Schema Registry.
276
279
277
-
## Using streams
280
+
###Using streams
278
281
279
282
* For most of the cases have your `Spec` extend the `EmbeddedKafkaStreamsWithSchemaRegistryAllInOne` trait. This offers both streams management and easy creation of consumers for asserting resulting messages in output/sink topics.
280
283
* If you only want to use the streams management without the test consumers just have the `Spec` extend the `EmbeddedKafkaStreamsWithSchemaRegistry` trait.
0 commit comments