JUnit Test exception occurred: Exception in thread "main" java.lang.NoSuchMethodError:org.junit.platform.commons.util.

Source: Internet
Author: User

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)
    • 1

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>
    • 1
    • 2
    • 3
    • 4
    • 5

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.