Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass

Tags:

I have the test that leads to error. I tried to execute it in the IntelliJ Idea 2018.3.2. All jupiter and junit dependencies have version RELEASE

The full text of error:

Dec 26, 2018 1:17:17 AM org.junit.platform.launcher.core.DefaultLauncher handleThrowable WARNING: TestEngine with ID 'junit-jupiter' failed to execute tests java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(Ljava/lang/String;)Lorg/junit/platform/commons/function/Try; at org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableCollector.createAbortedExecutionPredicate(OpenTest4JAndJUnit4AwareThrowableCollector.java:40) at org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableCollector.<clinit>(OpenTest4JAndJUnit4AwareThrowableCollector.java:30) at org.junit.jupiter.engine.support.JupiterThrowableCollectorFactory.createThrowableCollector(JupiterThrowableCollectorFactory.java:34) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:68) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) 

the test has the following view

import biz.Services.msg.BookTimeMsgService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import static org.junit.jupiter.api.Assertions.assertTrue;  @ExtendWith(MockitoExtension.class) public class MsgReceiverTest {  @Mock BookTimeMsgService bookTimeMsgService;  @InjectMocks MsgReceiver msgReceiver;  @Test public void msgReceiverTest_bookTimeServiceShouldObtainMsg() {     assertTrue(true); } 

part of my pom.xml

<parent>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-parent</artifactId>     <version>2.1.1.RELEASE</version> </parent>     <dependency>         <groupId>org.springframework.boot</groupId>         <artifactId>spring-boot-starter-test</artifactId>         <scope>test</scope>     </dependency>      <dependency>         <groupId>org.junit.jupiter</groupId>         <artifactId>junit-jupiter-api</artifactId>         <version>RELEASE</version>         <scope>test</scope>     </dependency>      <dependency>         <groupId>org.junit</groupId>         <artifactId>junit-bom</artifactId>         <version>RELEASE</version>         <type>pom</type>         <scope>test</scope>     </dependency>      <dependency>         <groupId>org.mockito</groupId>         <artifactId>mockito-junit-jupiter</artifactId>         <version>RELEASE</version>         <scope>test</scope>     </dependency> 

How to fix the issue?

like image 574
Bizon4ik Avatar asked Dec 25 '18 23:12

Bizon4ik


People also ask

What is JUnit platform launcher?

platform. launcher. Public API for configuring and launching test plans. This API is typically used by IDEs and build tools.

What is org JUnit Jupiter?

JUnit Jupiter is the combination of the programming model and extension model for writing tests and extensions in JUnit 5. The Jupiter sub-project provides a TestEngine for running Jupiter based tests on the platform. JUnit Vintage provides a TestEngine for running JUnit 3 and JUnit 4 based tests on the platform.

What is JUnit bom?

The junit-bom is JUnit's Bill Of Materials (BOM). When including this BOM, it will ensure to align and manage all JUnit 5 dependency versions for you.


1 Answers

I changed the version of jupiter and junit to 5.3.2 and the problem has gone

like image 79
Bizon4ik Avatar answered Sep 22 '22 19:09

Bizon4ik