[英]About with(any(Class.class))) with JMock
With JMock: 使用JMock:
context.checking(new Expectations() {{
// Other oneOf() will() statements ...
oneOf(shopAccount).enter(100, with(any(String.class)));
will(returnValue(true));
// Other oneOf() will() statements ...
}});
The following exception will be raised during execution: 执行期间将引发以下异常:
java.lang.IllegalArgumentException: not all parameters were given explicit matchers: either all parameters must be specified by matchers or all must be specified by values, you cannot mix matchers and values.
java.lang.IllegalArgumentException:并非所有参数都被赋予显式匹配器:要么所有参数都必须由匹配器指定,要么所有参数都必须由值指定,您不能混合使用匹配器和值。
Why i cannot do this way? 为什么我不能这样做? using
with(any(Klass.class))
? 使用
with(any(Klass.class))
?
if you use a with
clause for any parameter, you must use them for all the parameters, try 如果对任何参数使用
with
子句,则必须将它们用于所有参数,请尝试
oneOf(shopAccount).enter( with(equalTo(100)) , with(any(String.class)));
oneOf(shopAccount).enter( with(equalTo(100)) ,with(any(String.class)));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.