-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on executing tests with spring-kafka-test 3.0.0 #2490
Comments
The new global embedded broker feature added a hard dependency for the platform launcher. As a work around, please use dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
testImplementation("org.junit.platform:junit-platform-launcher:1.9.1")
testImplementation("org.springframework.kafka:spring-kafka-test:3.0.0")
} With the non-boot version. With boot, you don’t need the version. |
@sbrannen Looking at the stack trace, it is clear that the launcher is on the gradle class path, but, obviously, not on the test runtime class path, while trying to load test execution listeners via the service loader. Do you think that this is something that JUnit and/or Gradle should handle, or are we forced to make the launcher a hard transitive dependency of spring-kafka-test? The latter doesn't seem right because (perhaps rarely) not all users will use JUnit. FWIW, I don't see the same problem with maven, and I don't see the launcher on the CP there either. cc/ @wilkinsona |
AIUI, Gradle offers better classpath separation than Maven does here. This means that the launcher isn't leaked into the classpath of the tests as it isn't typically needed. I have a feeling that |
So, there is something wrong with class loader manipulations in JUnit by itself:
The I'm not sure though how then that out-of-the-box /CC @sbrannen |
@sbrannen - we need some guidance here, please; thanks! |
That's correct. The JUnit Platform However, if that's necessary, then it's expected that the build include the For example, adding the following to the supplied sample project allows it to build.
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.9.0")
That's a bit tricky to assess. A Whereas, a global Jupiter So there are pros and cons for each approach. |
I don't think that's the case. If the Rather, I believe that the |
Thanks; I am concerned about adding it as a transitive dependency because it is possible someone might want to use the jar without any JUnit deps (I guess we could document that it can/should be excluded in that case). This might be the least path of resistance. This is currently a big problem for anyone using initializr (with gradle as the target) because it will always fail this way, until the user adds the dep. I would like to resolve it before Boot 3.0.1 (I have an SK 3.0.1 scheduled for that on Dec 19). One more option might be for initializr to add the dependency only if gradle is selected, but that seems a bit smelly and it would only help boot users (although I am sure there are not many of those and only a small subset of those might not be using JUnit). cc/ @snicoll |
If users are going to use our |
Yes; you are right, but that doesn't help with the unnecessary transitive dep for non-gradle users. However, even now, we have a transitive dep on the jupiter API due to the condition, so maybe I am worrying too much. We can just add the launcher as a dep and document that the two deps can be excluded if not needed because JUnit is not being used. |
Resolves spring-projects#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.
Resolves spring-projects#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.
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.
@garyrussell I have a similar problem using: Boot: 3.0.0 My tests run fine, however I get a warning in the maven log When looking at the dump file mentioned in the warning it says:
I can however confirm, that the problem goes away when upgrading spring-kafka-test to 3.0.1 |
I don't know if this issue is the same as what I've been through, but when I added the library( And when I saw this PR and removed it, it ran normally. condition
below error is Mine
|
It is the same. The work around was to add the launcher dependency, not spring-Kafka-test. It is fixed in 3.0.1. |
In what version(s) of Spring for Apache Kafka are you seeing this issue?
3.0.0
Describe the bug
There's a problem executing tests when using the spring-kafka-test 3.0.0
To Reproduce
./gradlew clean build
(will work fine)./gradlew clean build
Expected behavior
The tests should be executed
Sample
with spring-boot 3.0.0 https://github.com/wilsonrf/spring-kafka-test-sample
without spring-boot 3.0.0 https://github.com/wilsonrf/spring-kafka-test-sample/tree/without-springboot
The text was updated successfully, but these errors were encountered: