【发布时间】:2013-11-20 18:11:23
【问题描述】:
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.equalTo;
assertThat(actual, hasItem(hasProperty("id", equalTo(1L))));
其中actual 是一个ID 为Long 的POJO。
我明白了,
类型中的方法assertThat(T, Matcher super T>) MatcherAssert 不适用于参数(列表, 匹配器>)
从各种文档和其他stackoverflow页面来看,它应该是有效的,但我得到了上述错误。
【问题讨论】:
-
请参阅“How to Ask”以及链接页面和“minimal reproducible example”。演示您遇到的问题的最少代码是什么,以及问题的解释,以及最少的输入数据和预期结果?我们需要能够复制问题,而这个示例代码不会这样做。
标签: java unit-testing hamcrest