title: Is this test robust? Can I use DispatchQueue.main.async() in a unit test?
body: <p>Simplifying a bit the code structure, I have a <code>UIViewController</code> with <code>viewDidLoad()</code> that calls a method that uses <code>DispatchQueue.main.async()</code> to wait for the main thread to execute the code.</p>
  
  <pre><code>viewDidLoad() {
     method()
  }
  
  method() {
     ...
     DispatchQueue.main.async() {
        ...some code...
     }
  }
  </code></pre>
  
  <p>My test also need to wait for the main thread before to call XCTAssertEqual.</p>
  
  <pre><code>func testSuccessRequest() {
          let exp = expectation(description: "labelText")
          let vc = ViewController.init()
          vc.request = SuccessRequest.init()
          vc.loadViewIfNeeded()
  
          DispatchQueue.main.async() {
              XCTAssertEqual(vc.label.text, "success")
              exp.fulfill()
          }
  
          waitForExpectations(timeout: 40, handler: nil)
  }
  </code></pre>
  
  <p>Is this test robust? Or could I have situations in which the assert code is called before the async?</p>