I have read through below discussions about testing asynchronous call in unit test
- Testing asynchronous call in unit test in iOS
- How to unit test asynchronous APIs?
- http://ift.tt/1jzQL6R.
All of them need a block parameter in the original function, my question is how to test asynchronous call without the block parameter.
Here is the function I want to test. Since this function don't have a completion handler block, I can't add __block BOOL done or [documentOpenExpectation fulfill] to unit test that mentioned in above discussions.
-(void)function {
NSManagedObjectContext *childContext = [[[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType] autorelease];
childContext.parentContext = self.managedObjectContext;
[childContext performBlock:^{
// Do something
}];
}
Aucun commentaire:
Enregistrer un commentaire