zoukankan      html  css  js  c++  java
  • Junit测试出现异常:Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.

    在进行单元测试时,测试出现异常

    pom.xml依赖如下

    <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>RELEASE</version>
    </dependency>

    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.3</version>
    <scope>test</scope>
    </dependency>

    问题原因
    错误就在pom.xml的依赖中,仔细查看控制台输出你会发现IntelliJ IDEA正在尝试使用JUnit5运行我的测试用例。
    at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)

    通过pom.xml发现,我希望使用JUnit4.12运行测试用例,我们查看pom.xml发现junit-jupiter-api这个依赖会导致这个错误。

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>RELEASE</version>
    </dependency>


    解决方案

    1、删除pom.xmlorg.junit.jupiter依赖
    2、Reimport All Maven Project

     
  • 相关阅读:
    Tips for Hoops 3D & ACIS
    把书读薄TICPP(2)
    Software Toolbox EasyOPC简介
    Wonderware InSQL and Incurity安装心得
    Linux root password reset
    SQL Server 2005 的搞笑
    SVG 简介
    M0n0wall 是什么?
    Solaris 上调试系统 hang 的总结
    DDNS简介
  • 原文地址:https://www.cnblogs.com/sujulin/p/7655418.html
Copyright © 2011-2022 走看看