From 78a9944b4bfad4c19cbe721876af912c89fc069d Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 30 Nov 2022 13:40:25 -0500 Subject: [PATCH] GH-2490: Add JUnit Platform Test Dependency Resolves https://github.com/spring-projects/spring-kafka/issues/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. --- build.gradle | 2 +- spring-kafka-docs/src/main/asciidoc/testing.adoc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 80b35e5fcc..d3d2158913 100644 --- a/build.gradle +++ b/build.gradle @@ -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") { diff --git a/spring-kafka-docs/src/main/asciidoc/testing.adoc b/spring-kafka-docs/src/main/asciidoc/testing.adoc index 708fadf9eb..568c36e209 100644 --- a/spring-kafka-docs/src/main/asciidoc/testing.adoc +++ b/spring-kafka-docs/src/main/asciidoc/testing.adoc @@ -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).