简体   繁体   中英

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

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)) ?

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)));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM