Skip to content

Instantly share code, notes, and snippets.

@ejeffers
Created September 14, 2012 21:10
Show Gist options
  • Save ejeffers/3724858 to your computer and use it in GitHub Desktop.
Save ejeffers/3724858 to your computer and use it in GitHub Desktop.
Async Unit Tests with Blocks - turns out, OCUnit doesn't provide a runLoop or anything like - so you gotta make your own
- (void)testFetchCrumbsForStartTime
{
[NSRunLoop currentRunLoop];
// use the downloader to "download" the data
UMEPGQueryManager *queryMan = [[UMEPGQueryManager alloc] init];
__block BOOL isDone = NO;
//Makes calls to several blocks, on different threads
[queryMan fetchChannelIdsWithCompletionHandler:^(NSArray *channelIds) {
//Verify results here
STAssertEquals(channelIds, verifiedChannelIds, @"your log message here");
isDone = YES;
}];
while (!isDone) {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment