Skip to content

Commit

Permalink
GH-2490: Add JUnit Platform Test Dependency
Browse files Browse the repository at this point in the history
Resolves #2490

The new global embedded kafka broker depends on the JUnit platform launcher.
With gradle, the launcher must be on the test runtime class path.
Add the launcher as a transitive dependency.

Tested with gradle and maven Boot apps.
  • Loading branch information
garyrussell authored and artembilan committed Nov 30, 2022
1 parent 46372df commit 78a9944
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ project ('spring-kafka-test') {
api "org.apache.kafka:kafka_$scalaVersion:$kafkaVersion"
api "org.apache.kafka:kafka_$scalaVersion:$kafkaVersion:test"
api 'org.junit.jupiter:junit-jupiter-api'
providedApi 'org.junit.platform:junit-platform-launcher'
api 'org.junit.platform:junit-platform-launcher'
optionalApi "org.hamcrest:hamcrest-core:$hamcrestVersion"
optionalApi "org.mockito:mockito-core:$mockitoVersion"
optionalApi ("junit:junit:$junit4Version") {
Expand Down
3 changes: 3 additions & 0 deletions spring-kafka-docs/src/main/asciidoc/testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ For example, a `spring.embedded.kafka.brokers.property=spring.kafka.bootstrap-se
NOTE: It is recommended to not combine a global embedded Kafka and per-test class in a single test suite.
Both of them share the same system properties, so it is very likely going to lead to unexpected behavior.

NOTE: `spring-kafka-test` has transitive dependencies on `junit-jupiter-api` and `junit-platform-launcher` (the latter to support the global embedded broker).
If you wish to use the embedded broker and are NOT using JUnit, you may wish to exclude these dependencies.

[[embedded-kafka-annotation]]
==== @EmbeddedKafka Annotation
We generally recommend that you use the rule as a `@ClassRule` to avoid starting and stopping the broker between tests (and use a different topic for each test).
Expand Down

0 comments on commit 78a9944

Please sign in to comment.