I am using Mockito to write my test case. I have a simple class which contains a function countPerson(boolean)
which I am interested to test:
public class School {
//School is a singleton class.
public void countPerson(boolean includeTeacher) {
if (includeTeacher) {
countIncludeTeacher();
return;
}
countOnlyStudents();
}
public void countIncludeTeacher() {...}
public void countOnlyStudents() {...}
}
In my unit test, I want to test the countPerson(boolean)
function:
public class SchoolTest{
private School mSchool;
@Before
public void setUp(){
mSchool = School.getInstance();
}
@Test
public void testCountPerson() {
mSchool.countPerson(true);
//How to test/verify countIncludeTeacher() is invoked once?
}
}
How to use Mockito to check/verify countIncludeTeacher()
is invoked once in my test case?