Eclipse Java IDE Junit5:junit.jupiter.api.sersertions无法访问
我是整个编程内容的新手,但这是我的问题:
我曾经通过右键单击该项目来添加Eclipse的Junit测试用例,只需添加 new> Junit测试案例。
当前,我无法实现任何测试方法,因为Eclipse在行上告诉我
import static org.junit.jupiter.api.Assertions.*;
错误消息
The type org.junit.jupiter.api.Assertions is not accessible.
错误我在IDE中获得的错误错误:
我尝试了以下内容:
- 使用新的工作场所重新安装Eclipse。
- 添加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:
I tried the following:
- Reinstalling Eclipse, using a fresh workplace.
- Adding the JUnit to Build path
Nothing helped.
It worked and works in older projects just fine.
Here is how the Package Explorer looks:
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 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 requiredrequires <module>;
statement. JPMS was introduced in Java 9.Do one of the following:
module-info.java
file (if needed, you can recreate it via right-clicking the project folder and choosing Configure > Create module-info.java)module-info.java
add the correspondingrequires
statement, e.g. by going to the line with theimport
statement and using the corresponding Quick Fix (Ctrl+1)我在一台计算机上的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.