I'm writing a JUnit test and also using Mockito, and I want to call a method, which in turn calls a second method a number of times. I do not want that second method to ever be called during my unit test, but I want to know what it's arguments would have been. My code to be tested looks something like this:
public class MyClass {
public void myMethod() {
int a = [do some logic]
int b = [do some logic];
doSomething(a, b);
a = [do some logic];
b = [do some logic];
doSomething(a, b);
}
public void doSomething(int a, int b) {
// code that I do not want to be executed during a unit test
}
}
And now a unit test:
@Test
public void test() {
MyClass myClass = new MyClass();
myClass.myMethod();
verify(myClass).doSomething(17, 33);
verify(myClass).doSomething(9, 18);
}
I am new to Mockito and I don't know if it's possible to either A) prevent doSomething() from being executed and B) verify the values of the a & b arguments. I'm willing to accept answers like "Mockito cannot help you here" or "this is not something that is technically possible." If there's no way to mock this sort of thing, I may consider refactoring those [do some logic] blocks into methods that I can test directly but my code is more complex than this simple example, and I am not allowed to post the code online.