I have a method that takes a response block and an error block, I write unit test by giving it valid data and invalid data so it will call response block and error block respectively, but with GHUnit and OCMock, how do I test if the correct block is called?
I was thinking:
for valid data:
response
{
GHAssertTrue(YES, @””);
}
error
{
GHAssertTrue(NO, @”Valid data should not call error block”);
}
and vice-versa for invalid data.
Is what I did correct?
The problem with putting your assertions in the blocks is that you wouldn’t know if neither block were called. This is what we do:
The drawback is that if the success block is never called, the tests will hang in the while loop. You could avoid that by adding a timeout: