I was using SenTestingKit, the default unit testing framework from Apple, when I found out that it does not support tests that involve asynchronous methods, or blocks.
-(void)testBlockMethod{dispatch_semaphore_tsemaphore=dispatch_semaphore_create(0);// Your block method eg. AFNetworkingNSURL*url=[NSURLURLWithString:@"http://httpbin.org/ip"];NSURLRequest*request=[NSURLRequestrequestWithURL:url];AFJSONRequestOperation*operation=[AFJSONRequestOperationJSONRequestOperationWithRequest:requestsuccess:^(NSURLRequest*request,NSHTTPURLResponse*response,idJSON){NSLog(@"IP Address: %@",[JSONvalueForKeyPath:@"origin"]);STAssertNotNil(JSON,@"JSON not loaded");// Signal that block has completeddispatch_semaphore_signal(semaphore);}failure:nil];[operationstart];// Run loopwhile(dispatch_semaphore_wait(semaphore,DISPATCH_TIME_NOW))[[NSRunLoopcurrentRunLoop]runMode:NSDefaultRunLoopModebeforeDate:[NSDatedateWithTimeIntervalSinceNow:10]];dispatch_release(semaphore);}