无法解析导入 (Junit)

Import cannot be resolved (Junit)

我正在尝试在 Maven 中使用 Eclipse IDE 在 Windows 上为我的项目编写单元测试。

我已经使用 Eclipse 插件在构建路径上导入了 jUnit4

(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 库还是有其他问题?

注意:Maven 中没有 JUnit 依赖项。我直接在构建路径中导入 JUnit jar。

编辑:我忘了提及,但我确实为 junit.Assert.

使用了静态

assertEquals 不是 class 而是一种方法,因此您必须选择:

进口org.junit.Assert;

并调用 Assert.assertEquals

或使用:

导入静态 org.junit.Assert.assertEquals;

并调用:assertEquals