I am attempting to mock the method below with JMock and I am running into a compiler error.
Class to Mock:
public interface myClass<T extends SomeClass>{
public void myMethod(T parameter);
public void myOtherMethod();
}
Mock Expectation:
exactly(1).of(myClassMocked).myOtherMethod();
exactly(1).of(myClassMocked).myMethod( with(any(SomeClass.class)) );
Compile Error:
The method myMethod(capture#6-of ?) in the type myClass is not applicable for the arguments (SomeClass)
I have attempted switching Object.class with other compatible classes and playing around with the matcher.
I am unable to simply change the method signature, that would be too easy.
The long and short of it is I want to ignore this particular method call but I cannot ignore the entire MyClass mock because it is a service I am using for other tasks in my test method.
EDIT:
The fix is to change
final myClass<?> myClassMocked= mockery.mock(myClass.class);
(generic specification suggested by eclipse) to
final myClass<SomeClass> myClassMocked= mockery.mock(myClass.class);