无法导入junit

huangapple go评论59阅读模式
英文:

Failed to import junit

问题

Sure, here's the translated content:

[![我的构建路径][1]][1]


[![Eclipse中的错误][2]][2]


  [1]: https://i.stack.imgur.com/hNKW7.png
  [2]: https://i.stack.imgur.com/YjyzU.png

这是Eclipse的一个错误吗?我尝试过刷新项目、重启Eclipse和系统,但仍然困惑。
英文:

无法导入junit

无法导入junit

Is it a bug in Eclipse? I have tried to refresh the project, restart Eclipse and system. Confused.

答案1

得分: 1

> 这是 Eclipse 中的一个 bug 吗?

不是。这是项目设置中的一个 bug。看起来项目的 Maven 依赖关系中 junit 的配置是错误的。

您正在为您尝试编译的测试代码使用错误的 Junit JAR 文件。junit.framework.TestCase 类来自 Junit 3,但您正在使用 Junit 4.7 的 JAR 文件。在 Junit 4.x 中,包名称更改为 org.junit,并且删除了 TestCase 类。

解决方案:

  1. 找到并使用最后一个 Junit 3.x 发行版的 JAR 文件。(这里 或许是您所需的版本…)
  2. 将您的测试用例更新为使用较新版本的 Junit。(最好是 Junit 5.x)

(撰写时,Junit 4.x 的最新版本是 4.13。)

英文:

> Is it a bug in Eclipse?

Nope. It is a bug in the project setup. It looks like the project's maven dependency for junit is incorrect.

You are using the wrong Junit JAR file for the test code you are trying to compile. The junit.framework.TestCase class is from Junit 3, but you are using the JAR file for Junit 4.7. In Junit 4.x the package names changed to org.junit, and the TestCase class was dropped.

Solutions:

  1. Find and use the JAR file for the last Junit 3.x release. (This might be what you need ...)
  2. Update your testcases to use a newer version of Junit. (Preferably Junit 5.x)

(At the time of writing, the latest release of Junit 4.x is 4.13.)

huangapple
  • 本文由 发表于 2020年9月3日 09:15:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63715452.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定