I don't quite follow what problem you're having using Mockito. Assuming you create a mock of the interface that contains your myMethod()
method, you can then verify only the parameters to the method that you are interested in. For example (assuming the interface is called MyInterface
and using JUnit 4):
@Test
public void test() {
MyInterface myInterface = mock(MyInterface.class);
FooBar expectedFooBar = new FooBar();
// other testing stuff
verify(myInterface).myMethod(any(), any(), eq(expectedFooBar), any(), ...);
}
You'll need to do a static import on the Mockito methods for this to work. The any()
matcher doesn't care what value has been passed when verifying.
You can't avoid passing something for every argument in your method (even if it's only NULL).