I want to test this method :
public void some_method(SomeFactory someFactory) {
A a = someFactory.populateWithParameter(parameter1, parameter2, parameter3, parameter4);
a.method_call();
....
}
the factory goes this way
public class SomeFactory(){
// some constructor
public A populateWithParameter(SomeClass1 someClass1, SomeClass2 someClass2, String string, int parameter){
return new A(someClass1, someClass2, string, parameter)
}
}
and the test is
public void testSomeMethod() throws Exception {
SomeFactory someFactory = mock(SomeFactory.class);
when(someFactory.populateWithParameter(
any(SomeClass1.class), any(SomeClass2.class),
anyString(), anyInt())).thenReturn(notNull());
mainActivity.some_method(someFactory);
...
}
I get this message
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers!
4 matchers expected, 1 recorded: