Hi I've start with start.spring.io just like below
and I was trying to check if test is okay or not by default.
but it wasn't even start to it. and I got this error in console instead of test results.
java.lang.NoSuchMethodError: 'java.util.Set org.junit.platform.engine.TestDescriptor.getAncestors()'
at org.junit.platform.launcher.core.StackTracePruningEngineExecutionListener.getTestClassNames(StackTracePruningEngineExecutionListener.java:50)
at org.junit.platform.launcher.core.StackTracePruningEngineExecutionListener.executionFinished(StackTracePruningEngineExecutionListener.java:39)
at org.junit.platform.launcher.core.DelegatingEngineExecutionListener.executionFinished(DelegatingEngineExecutionListener.java:46)
at org.junit.platform.launcher.core.OutcomeDelayingEngineExecutionListener.reportEngineFailure(OutcomeDelayingEngineExecutionListener.java:83)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:203)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:169)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:93)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:58)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:141)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:57)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:103)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:94)
at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:52)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:70)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
I googled. people said that it was seemed that related with jupiter-api version. so I added some dependencies like this. but it didn't work.
// build.gradle
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.3'
id 'io.spring.dependency-management' version '1.1.3'
}
group = 'hello'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation('org.junit.jupiter:junit-jupiter-api:5.9.3') /// added version
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.9.3') /// added version
}
tasks.named('test') {
useJUnitPlatform()
}
I also tried in different way. I added Java Build Path on my Eclipse IDE but it didn't work too.
(right click on my project > Properties > Java Build Path
> Modulepath(already tried classpath too.) > Add Library > JUnit
I didn't see same case about JUnit error with 'java.util.Set org.junit.platform.engine.TestDescriptor.getAncestors()'
.
so I'm confused now. please help.
This seems an issue of Eclipse Buildship with JUnit less than 5.10.0 and Eclipse 2023-09 (4.29) which I reported here:
Workarounds:
build.gradle
, add the dependency testImplementation 'org.junit.platform:junit-platform-launcher:1.9.3'
ortestImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
build.gradle
Cause:
It seems Buildship does not choose the corresponding junit-platform-launcher
(as m2e seems to do; at least this issue cannot be reproduced with Maven), but uses the junit-platform-launcher
version that is shipped with Eclipse. And in Eclipse 4.29 junit-platform-launcher
has been upgraded to 1.10.0. But org.junit.platform:junit-platform-launcher:1.10.0
calls org.junit.platform.engine.TestDescriptor.html::getAncestors
which has been introduced in org.junit.platform:junit-platform-engine:1.10.0
and which is missing in org.junit.platform:junit-platform-engine:1.9.3
in JUnit 5.9.3.