这是代码:
Map<Foo, String> map;
org.hamcrest.MatcherAssert.assertThat(map,
org.hamcrest.Matchers.hasKey(new Foo()));
这是编译器的意思:
cannot find symbol method assertThat(java.util.Map<Foo,java.lang.String>,
org.hamcrest.Matcher<java.util.Map<Foo,java.lang.Object>>)
为什么以及我能做什么?
最佳答案
我怀疑你需要这样的东西:
MatcherAssert.assertThat(map, Matchers.<Foo, String>hasKey());
这样您就可以为 hasKey
方法调用指定值类型。虽然看起来很丑,我有点惊讶类型推断对你没有帮助......
关于java - 我无法编译 hamcrest hasKey() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6865991/