[英]How to debug an error of “The method or Matcher in the type X is not applicable for the arguments”?
public class JUnitTest {
@Autowired ApplicationContext context;
static Set<JUnitTest> testObjects = new HashSet<JUnitTest>();
static ApplicationContext contextObject = null;
@Test public void test3() {
assertThat(testObjects, not(hasItem(this)));
testObjects.add(this);
assertThat(contextObject, either(is(nullValue())).or(is(this.context))); //error
contextObject = this.context;
}
}
Error message: 错误信息:
The method or(Matcher< ? super Object >) in the type
CombinableMatcher.CombinableEitherMatcher< Object> is not applicable for the
arguments (Matcher< ApplicationContext>)
How to fix this code? 如何修复此代码?
您可以将类型指定为nullValue
的参数,以使其返回适当的类型。
assertThat(contextObject, either(is(nullValue(ApplicationContext.class))).or(is(this.context)));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.