title: XCTest: Test asyncronous function without completion block
body: <p>I want to test a function in which an asynchronous task is called (async call to a webservice):</p>
  <pre><code>+(void)loadAndUpdateConnectionPool{
  
    //Load the File from Server
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *responseCode, NSData *responseData, NSError *error) {
      NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)responseCode;
      if([httpResponse statusCode] != 200){
          // Show Error 
      }else{
          // Save Data
          // Post Notification to View
      }
    }];
  
  }
  </code></pre>
  <p>Since the function doesn't have a completion handler, how can I test this in my XCTest class?</p>
  <pre><code>-(void)testLoadConnectionPool {
  
    [ConnectionPool loadAndUpdateConnectionPool];
  
    // no completion handler, how to test?
    XCTAssertNotNil([ConnectionPool savedData]);
  
  }
  </code></pre>
  <p>Is there any best practice, like a timeout or anything? (I know I can't use <code>dispatch_sempaphore</code> without redesigning the <code>loadAndUpdateConnectionPool</code> function).</p>