我正在尝试使用Windows上的Maven
IDE在Eclipse
中为我的项目编写单元测试。
我使用jUnit4
插件在构建路径上导入了Eclipse
。
(junit.jar under /path/to/eclipse/plugins/org.junit4.12.0.v201504281640).
我可以导入这些。 (古怪)
import org.junit.Test;
import org.junit.runner.RunWith;
但我导入这些
有问题import static org.junit.Assert.assertEquals;
import org.junit.Before;
我是否必须添加另一个JUnit
库,还是有其他问题吗?
注意:JUnit
中没有Maven
个依赖项。我正在构建路径中直接导入JUnit
jar。
编辑:我忘了提,但我确实使用静态junit.Assert
。
答案 0 :(得分:1)
assertEquals不是一个类,而是一个方法所以你必须选择:
import org.junit.Assert;
并调用Assert.assertEquals
或使用:
import static org.junit.Assert.assertEquals;
并致电:assertEquals