【发布时间】:2010-12-21 17:32:37
【问题描述】:
试图编译这段代码
import static org.hamcrest.Matchers.is;
import static org.hamcrest.number.OrderingComparison.lessThan;
...
Assert.assertThat(0, is(lessThan(1)));
发出此编译错误:
assertThat(Object, org.hamcrest.Matcher<java.lang.Object>)不能应用于(int, org.hamcrest.Matcher<capture<? super java.lang.Integer>>)
这可能是不同 hamcrest 版本之间的冲突吗? 我正在使用 jUnit 4.6 和 hamcrest 1.3
【问题讨论】:
-
只有一份 hamcrest 不会有冲突。你有哪些版本的 JUnit 和 Hamcrest?请记住,更高版本的 JUnit 包含他们自己的 Hamcrest 位副本。
-
我最近添加了 hamcrest,之前只使用了 jUnit。与 jUnit 捆绑的 hamcrest 可能较旧,应该更新。
标签: java unit-testing junit hamcrest