Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 787
Édipo Féderle Avatar asked Apr 23 '11 01:04

Édipo Féderle


People also ask

What is jMock in Java?

JMock is a library that supports test-driven development of Java code with mock objects . Mock objects help you design and test the interactions between the objects in your programs. The jMock library: makes it quick and easy to define mock objects, so you don't break the rhythm of programming.


1 Answers

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

like image 175
Steve Freeman Avatar answered Oct 08 '22 05:10

Steve Freeman