我的程序包属于Junit(在org.junit, org.junit.experimental.results, org.junit.internal, org.junit.internal.matchers, org.junit.matchers, org.junit.rules
中)的项目中出现了编译错误。
所有这些类都在我的项目中的junit包下,意思是:Security/src/org.junit, Security/src/org.junit.experimental.results
,其中Security
是我项目的名称。我编写的类是在我定义的其他包中:Security/src/myPackage/myClass
在所有这些类中,它在导入行中给出了一个编译错误,例如:
import org.hamcrest.Description cannot be resolved
import org.hamcrest.Matcher cannot be resolved;
import static org.junit.matchers.JUnitMatchers.containsString cannot be resolved;
检查正常(显示绿色/红色条,并给出正确的结果),但是这个问题在所有项目上都给出了错误。
答案 0 :(得分:4)
您的JUnit版本需要Hamcrest。您应该将它包含在构建路径中或使用较旧的JUnit版本。
版本4.10有不同的JUnit包: