I'm new to OCMock and had a question.
Can we stub a method of a class, where calling that method over any instance/object of that class gets mocked
For Example : if Class_A has a non static function_a and Class_B has function_b which internally declares a object_o of Class_A.
Class_A
{
- function_a
}
Class_B
{
- function_b
{
Obj_o of Class A
[Obj_o a];
}
}
Now, I want to write unit test for Class_B and test function_b.
Is there some mechanism where I create a mock of Class_A and stub function_b and then run the test function_b and be sure that function_b got stubbed.
I know that if I change the function definition of function_b to have the object_o sent as a parameter, it works. We create an object mock of class_A, stub for function_b, and send that object mock as a parameter to function_b because it gets the reference for the mocked object. But I want to check regarding the feasibility of testing such functions without changing the function definitions. Does OCMock provide such functionality.