Junit4: 带有 JUnit 4.11 的 Hamcrest-all 1.3 抛出异常

创建于 2014-04-09  ·  4评论  ·  资料来源: junit-team/junit4

你好,

在 ExpectedException 类中有这个导入:
import static org.hamcrest.CoreMatchers.containsString;
如果您使用 hamcrest-all 则无法解决,因为 containsString 方法在org.hamcrest.Matchers.

hamcrest

最有用的评论

您应该始终避免将 hamcrest-all 与 JUnit 一起使用,因为 hamcrest-all 包含 hamcrest-core 的类。 如果您需要的不仅仅是核心匹配器,请使用hamcrest-library

所有4条评论

啊,虚报。 事实证明,mockito-all 1.9.5 集成了导致问题的 hamcrest。 对不起。

@apreg ,你是如何解决这个问题的?

对不起,我不记得了

您应该始终避免将 hamcrest-all 与 JUnit 一起使用,因为 hamcrest-all 包含 hamcrest-core 的类。 如果您需要的不仅仅是核心匹配器,请使用hamcrest-library

此页面是否有帮助?
0 / 5 - 0 等级