Java 无法解析导入(Junit)
我试图在Windows上使用Java 无法解析导入(Junit),java,unit-testing,junit,junit4,Java,Unit Testing,Junit,Junit4,我试图在Windows上使用EclipseIDE在Maven中为我的项目编写单元测试 我已经使用Eclipse插件在构建路径上导入了jUnit4 (junit.jar under /path/to/eclipse/plugins/org.junit4.12.0.v201504281640). 我可以进口这些。(奇怪地) 但我在导入这些时遇到了问题 import static org.junit.Assert.assertEquals; import org.junit.Before; 我是
Eclipse
IDE在Maven
中为我的项目编写单元测试
我已经使用Eclipse
插件在构建路径上导入了jUnit4
(junit.jar under /path/to/eclipse/plugins/org.junit4.12.0.v201504281640).
我可以进口这些。(奇怪地)
但我在导入这些时遇到了问题
import static org.junit.Assert.assertEquals;
import org.junit.Before;
我是否必须添加另一个JUnit
库,或者是否存在其他问题
注意:Maven
中没有JUnit
依赖项。我直接在构建路径中导入JUnit
jar
编辑:我忘了提到,但我确实为junit使用了static。AssertassertEquals不是一个类,而是一个方法,因此您必须选择: 导入org.junit.Assert 并调用Assert.assertEquals 或使用: 导入静态org.junit.Assert.assertEquals
并调用:assertEquals为什么不使用它?为什么不为此使用pom依赖项?对于assertEquals,它不应该是导入静态的吗?
import static org.junit.Assert.assertEquals;
import org.junit.Before;