Junit testing for a function

Viewed 245

I have a confusion regarding Junit testing.For some functions(add function) with closed business logic we can make unit testing by asserting the function.

For example

public int add(int a,int b){
  int c = a+b;
  return c;
}

But for some function(as below example) in a route what methodology we have to do.

For example

public int foo(int totalnum){
  Zoo soo = new Zoo();
  int giraffNumber = soo.giraffe(totalnum);//here we are calling another method
  return giraffNumber;
}

For these kind of methods what approach we have to do.Does we need to write another class.

Can anybody please advise me with an example.

2 Answers
Related