Eclipse Java IDE Junit5:junit.jupiter.api.sersertions无法访问

发布于 2025-01-24 05:25:49 字数 848 浏览 4 评论 0原文

我是整个编程内容的新手,但这是我的问题:

我曾经通过右键单击该项目来添加Eclipse的Junit测试用例,只需添加 new> Junit测试案例

当前,我无法实现任何测试方法,因为Eclipse在行上告诉我

import static org.junit.jupiter.api.Assertions.*;

错误消息

The type org.junit.jupiter.api.Assertions is not accessible.

错误我在IDE中获得的错误错误:

“在此处输入图像说明”

我尝试了以下内容:

  1. 使用新的工作场所重新安装Eclipse。
  2. 添加Junit来构建道路

没什么帮助。

它起作用,在较旧的项目中工作很好。

这是包装浏览器的外观:

”在此处输入图像描述”

我缺少什么?

I'm new to the whole programming stuff but here's my problem:

I used to add my JUnit test cases in Eclipse by right clicking on the project, and just add New > JUnit Test Case.

Currently, I am not able to implement any test methods because Eclipse tells me on the line

import static org.junit.jupiter.api.Assertions.*;

the error message

The type org.junit.jupiter.api.Assertions is not accessible.

Error I get in the IDE:

enter image description here

I tried the following:

  1. Reinstalling Eclipse, using a fresh workplace.
  2. Adding the JUnit to Build path

Nothing helped.

It worked and works in older projects just fine.

Here is how the Package Explorer looks:

enter image description here

What am I missing?

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

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

发布评论

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

评论(2

不甘平庸 2025-01-31 05:25:49

您可以使用 java平台模块系统(jpms) 在默认软件包中的文件可能没有必需的需要< module&gt ;;语句。 jpms是在Java 9中引入的。

执行以下操作之一:

  • 删除module-info.java file(如果需要的话,可以通过右键单击项目文件夹并选择配置&gt来重新创建它;在Module-info.java中创建模块info.java
  • 添加相应的需要语句语句,并使用相应的快速修复 ctrl + 1

You use the Java Platform Module System (JPMS) by having a module-info.java file in the default package probably without the required requires <module>; statement. JPMS was introduced in Java 9.

Do one of the following:

  • Delete the module-info.java file (if needed, you can recreate it via right-clicking the project folder and choosing Configure > Create module-info.java)
  • In module-info.java add the corresponding requires statement, e.g. by going to the line with the import statement and using the corresponding Quick Fix (Ctrl+1)
酷遇一生 2025-01-31 05:25:49

我在一台计算机上的Eclipse IDE上也遇到了这个问题,但是在另一台具有新鲜IDE安装的计算机上没有发生。那是可疑的。我试图导出/导入所有设置,重新接口所有项目,甚至删除其IDE配置文件,没有任何帮助。

然后,我比较了两台计算机上安装在Eclipse IDE中的插件,并且发现了一些差异,因此我卸载了所有提及M2E的内容,然后再次安装了基本M2E(重新启动后)。

问题已经消失了。

请注意,JPMS中没有“测试模块信息”支持,因此每个工具都有自己的解决方案。

I had this issue too on my Eclipse IDE on one computer, but it was not happening on another computer with fresh IDE installation. That was suspicious. I tried to export/import all settings, reimport all projects, even removing their IDE configuration files, nothing helped.

Then I compared plugins installed in Eclipse IDE on both computers and I have found some differences, so I uninstalled everything mentioning M2E, and then installed just basic M2E again (after restart).

The problem has gone.

Note that there is no "test module info" support in JPMS, so every tool has it's own solution.

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