1
當我運行下面的JUnit測試:「沒有合適的方法,找到」使用hasItem Hamcrest匹配器時
@Test
public void test(){
List<Map<String,String>> data=new ArrayList<>();
Map<String,String> map=new HashMap<>();
map.put("x","y");
data.add(map);
assertThat(data, hasItem(hasKey("x")));
}
我得到這個:
Error:(239, 9) java: no suitable method found for assertThat(java.util.List>,org.hamcrest.Matcher>>) method org.junit.Assert.assertThat(java.lang.String,T,org.hamcrest.Matcher) is not applicable (cannot infer type-variable(s) T (actual and formal argument lists differ in length)) method org.junit.Assert.assertThat(T,org.hamcrest.Matcher) is not applicable (inferred type does not conform to upper bound(s) inferred: java.util.List> upper bound(s): java.lang.Iterable>,java.lang.Object)
它看起來像在仿製藥的東西被打破。它是什麼?