使用 JMock:
context.checking(new Expectations() {{
// Other oneOf() will() statements ...
oneOf(shopAccount).enter(100, with(any(String.class)));
will(returnValue(true));
// Other oneOf() will() statements ...
}});
执行期间将引发以下异常:
java.lang.IllegalArgumentException:并非所有参数都被明确匹配:要么所有参数都必须由匹配器指定,要么所有参数都必须由值指定,你不能混合匹配器和值。
为什么我不能这样做?使用with(any(Klass.class))
?