I am attempting to write unit tests for an iOS application which makes use of the Parse backend framework, and after much experimentation seem to be failing at writing successful unit tests. I have found a few posts on testing asynchronous code (Testing asynchronous call in unit test in iOS) and testing network calls, but am yet to find a way of testing calls to the Parse backend with async callbacks.
To give an example, could anyone advise how I would test the following line of code:
[PFUser saveUser:userModelMock withBlock:^(BOOL success, NSError *error) {
}];
I am using OCMock and the XCTest framework.
Any help would be much 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];
}