java junit抛出了错误:线程中的异常。 java.lang.nosuchmethoderror:' org.junit.runner.description

发布于 2025-02-13 15:50:51 字数 1220 浏览 0 评论 0原文

我有一些针对我在Java的应用程序的JUNIT测试用例,这很好。现在,我突然无法运行它,并在我的Intellij IDE中遇到关注错误。


Exception in thread "main" java.lang.NoSuchMethodError: 'org.junit.runner.Description org.junit.runner.Description.createTestDescription(java.lang.Class, java.lang.String)'
    at com.intellij.junit4.JUnit4TestRunnerUtil.buildRequest(JUnit4TestRunnerUtil.java:132)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:47)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

我不确定是什么原因引起了问题。以下是与项目相关的一些规格:

  1. Java版本:17
  2. 我的Maven POM中有关注依赖性:
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <scope>test</scope>
</dependency>

有人可以让我知道这里可能出了什么问题以及如何解决这个问题吗?

I have a few Junit test cases written specific for my application in Java which was working pretty fine. Now all of a sudden I am unable to run it and getting following error in my Intellij IDE.


Exception in thread "main" java.lang.NoSuchMethodError: 'org.junit.runner.Description org.junit.runner.Description.createTestDescription(java.lang.Class, java.lang.String)'
    at com.intellij.junit4.JUnit4TestRunnerUtil.buildRequest(JUnit4TestRunnerUtil.java:132)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:47)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

I am not sure whats causing the issue. Following are some of the specifications related to the project:

  1. Java Version: 17
  2. I have following dependency in my Maven POM:
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <scope>test</scope>
</dependency>

Can someone please let me know what could be wrong here and how to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过期以后 2025-02-20 15:50:55
  1. 请确保在 pom.xml 中添加依赖项
    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.9.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
  1. ,运行命令,以
mvn clean install
  1. 在Maven图标上安装项目中的依赖项,请确保其他Junit依赖关系不会串通。

  1. Make sure to add dependencies in pom.xml
    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.9.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
  1. Run the command, to install the dependencies in the project
mvn clean install
  1. On the Maven icon, make sure that other JUnit dependencies are not colluding.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文