title: Why is runloop called when testing
body: <p>I usually see <code>RunLoop.current.run(until: Date())</code> called in integration tests. </p>
  
  <p>For example in <a href="https://clean-swift.com/how-to-test-your-viewdidload-method/" rel="nofollow noreferrer">this article</a> and in this <a href="https://github.com/FancyPixel/gulps/blob/master/GulpsTests/DrinkViewControllerTests.swift" rel="nofollow noreferrer">open source project</a>.</p>
  
  <p>The explanation given in the article is </p>
  
  <blockquote>
    <p>The RunLoop.current.run(until: Date()) statement makes sure the run loop associated with the current thread has ample time to let the drawing operations to complete</p>
  </blockquote>
  
  <p>If that is true why wouldn't we give it more time, how do we know that <code>Date()</code> is enough? </p>
  
  <p>I read a few articles about the run loop and it seems to me like the reason that line of code is added is to start the app. It seems like the appDelegate usually automatically triggers or starts the run loop, but since we are testing we need to trigger the run loop ourselves. </p>
  
  <p>I might be missing some fundamental understand of threads or run loops but I hope that someone can give some insight. </p>