About with(any(Class.class))) with JMock

元气小坏坏 提交于 2019-11-30 21:51:43

问题


With 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.

Why i cannot do this way? using with(any(Klass.class)) ?


回答1:


if you use a with clause for any parameter, you must use them for all the parameters, try

oneOf(shopAccount).enter(with(equalTo(100)), with(any(String.class)));



来源:https://stackoverflow.com/questions/5761529/about-withanyclass-class-with-jmock

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!