I am trying to write unit tests for an iOS application that uses the Parse framework, and after many experiments, it seems to fail when writing successful unit tests. I found several messages on testing asynchronous code ( Testing an asynchronous call in unit test in iOS ) and testing network calls, but I have not yet found a way to test calls to the Parse server with asynchronous callbacks.
To give an example, can someone tell me how I will test the following line of code:
[PFUser saveUser:userModelMock withBlock:^(BOOL success, NSError *error) {
}]
I use OCMock and the XCTest framework.
Any help would be greatly appreciated.
* EDIT *
This is what I have so far, but seems to be failing.
- (void)testSaveUser {
id userModelMock = [OCMockObject niceMockForClass:[UserModel class]];
id userControllerMock = [OCMockObject niceMockForClass:[self.userController class]];
[[userModelMock expect] saveInBackgroundWithBlock:[OCMArg any]];
[[userControllerMock stub] saveUser:userModelMock withBlock:[OCMArg any]];
[userModelMock verify];
}