【问题标题】:JUnit version warning on IntelliJIntelliJ 上的 JUnit 版本警告
【发布时间】:2021-08-09 14:06:07
【问题描述】:

我正在尝试在 IntelliJ 上运行测试方法,但是当我编译代码时,我收到以下警告:

WARNING: TestEngine with ID 'junit-vintage' failed to discover tests
org.junit.platform.commons.JUnitException: Failed to parse version of junit:junit: 4.13.1
    at org.junit.vintage.engine.JUnit4VersionCheck.parseVersion(JUnit4VersionCheck.java:54)
    at org.junit.vintage.engine.JUnit4VersionCheck.checkSupported(JUnit4VersionCheck.java:37)
    at org.junit.vintage.engine.JUnit4VersionCheck.checkSupported(JUnit4VersionCheck.java:32)
    at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:61)

在此警告之后,编译器构建成功并且测试工作。 (我正在使用gradle)

代码: img1

img2

img3

【问题讨论】:

  • 你是否在依赖项中添加了junit-vintage-engine
  • 请提供问题的代码示例。谢谢
  • 我没有添加junit-vintage-engine。如何添加junit-vintage-engine?我在答案中添加了代码。这是我第一次在 intelliJ 上编写测试类
  • 你想使用 JUnit 4 还是 JUnit 5 ?你的 Maven pom.xml 或 Gradle build.gradle 是什么样的?
  • 我想使用 JUnit 5

标签: java testing intellij-idea junit


【解决方案1】:

您在 build.gradle 中声明了 JUnit 4 和 JUnit 5。

移除 JUnit 4 依赖:

testImplementation('junit:junit:4.13')

然后在 IntelliJ 中重新同步/重新导入您的项目。

【讨论】:

    猜你喜欢
    • 2016-05-10
    • 2011-01-26
    • 1970-01-01
    • 1970-01-01
    • 2016-08-22
    • 2017-05-19
    • 1970-01-01
    • 2012-07-27
    • 1970-01-01
    相关资源
    最近更新 更多