Test exception occurs when unit tests are in progress
in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader;
The error is in pom.xml
the dependency, look carefully at the console output and you will find that IntelliJ idea is trying to run my test case using JUNIT5.
com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)
By pom.xml
discovering that I wanted to run the test case using JUnit4.12, we looked at the pom.xml
discovery that junit-jupiter-api this dependency could lead to this error.
<dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>RELEASE</version></dependency>
Because this module is designed for JUnit5-https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
Solution Solutions
1. pom.xml
Dependencies in org.junit.jupiter
deletion
2. Reimport all Maven Project
Original (English) address: https://stackoverflow.com/questions/45004453/ Cannot-run-tests-intellij-spring-project-error-java-lang-nosuchmethoderror
JUnit Test exception occurred: Exception in thread "main" java.lang.NoSuchMethodError:org.junit.platform.commons.util.