i am doing unit tests for my program, but i got a problem. i don't know how to deal with the situation that function A calls function and i am just going to test function A. it is said that i am supposed to create a stub module to simulate function as stub module. but i just don't know how to do this by JUnit
.
for example:
public class compute
{
public int multiply(int a,int b)
{
return a*b;
}
public int cube(int a)
{
return(multiply(multiply(a,a),a);
}
}
So, in this case, how to write test code for function cube()
? how to simulate multiply()
?