spring-bootjunitspring-tool-suitespring-tools-4

NoSuchMethodError: 'java.util.Set org.junit.platform.engine.TestDescriptor.getAncestors()


I get this error while running a JUnit test in Spring Tool Suite (4.20.0).

Test runs fine, but this error is thrown at the end -

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)

This is my Gradle plugins section -

plugins {
    id 'java'
    id 'eclipse'
    id 'eclipse-wtp'
    id 'org.springframework.boot' version "3.1.4"
    id 'io.spring.dependency-management' version "1.1.3"
}

This is my Gradle dependencies section -

implementation("org.springframework.boot:spring-boot-starter-parent:3.1.4")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-configuration-processor")
implementation("org.springframework.boot:spring-boot-starter-test")

What am I doing wrong?

My test class is very basic -

@ExtendWith(SpringExtension.class)
@ContextConfiguration(initializers = ConfigDataApplicationContextInitializer.class, classes = { TransformService.class})
@Slf4j
public class TransformServiceTest {

    @Autowired
    TransformService transformService;

    @Test
    public void transformXmlTest() throws Exception {
        transformService.transformXml();
    }
}

So, is my service class -

@Service
@Slf4j
public class TransformService {

    public void transformXml() {
        log.info("Transforming XML");
    }
}

I am running the test in STS by right-clicking on "TransformXmlTest()" in the Package Explorer and clicking "Run as - JUnit Test". (When I run it outside STS using Gradle task, everything looks clean).

This is the full log entry -

OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2023-10-06 10:00:33.097  INFO Transforming XML | com.dowill.xsl.service.TransformService
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)

Thank you for the help


Solution

  • I switched to STS 4.19.0 and not seeing this error anymore. Wonder if this is an issue with STS 4.20.0.

    I have tagged spring-tools-4 here hoping that someone from the STS community will take a look.