I'm trying to use JUnit and Mockito to mock a end-to-end method (addSomething method). It's obvious that inside that method I use other methods. My doubts are:
- To mock the end-to-end method I need to mock the other methods too, right?
- How can I mock the methods that are inside the addSomething method?
A simple example for what I want is:
METHOD A
public int summing(int sum){
int A = 5;
int B = 23;
sum = SumOfIntegers(A,B);
return sum;
}
METHOD B
private int SumOfIntegers(int number1, int number2){
try{
result = number1 + number2;
}catch (Exception e) {
e.printStackTrace();
}
return result;
}
How do I mock the class's method A since it's calling a private method?