title: Why GCD dispatch group notify is not called in Playground and Unit tests
body: <p>I have the code working in simulator/device and I'm trying to write unit tests for it. However, notify callback is not called in unit tests. Here's is a code for Playgrounds which is also not calling notify callback. I suspect it I may be using the wrong queue, but cannot figure out which one I should use.</p>
  
  <pre><code>import UIKit
  
  class Loader {
  
      func fetch(callback: ((_ result: String)-&gt; Void)) {
  
          callback("SomeString")
      }
  }
  
  class MyService {
  
     var list: Array&lt;String&gt; = Array()
     var loader: Loader = Loader()
     var dispatchGroup = DispatchGroup()
  
      func loadList(callback: @escaping (()-&gt; Void)) {
  
         for i in 1...3 {
  
             self.dispatchGroup.enter()
  
             self.loader.fetch(callback: { [weak self] (string) in
  
                 self?.list.append(string)
                 self?.dispatchGroup.leave()
             })
         }
  
         dispatchGroup.notify(queue: .main) {
  
             callback()
         }
     }
  }
  
  var service = MyService()
  service.loadList {
  
      print("Done is not called")
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Thanks to @paulvs, we need to enable indefinite execution. However, how to enable that for unit tests?</p>
  
  <pre><code>import UIKit
  import PlaygroundSupport
  
  class Loader {
  
      func fetch(callback: ((_ result: String)-&gt; Void)) {
  
          callback("SomeString")
      }
  }
  
  class MyService {
  
      var list: Array&lt;String&gt; = Array()
      var loader: Loader = Loader()
      var dispatchGroup = DispatchGroup()
  
      func loadList(callback: @escaping (()-&gt; Void)) {
  
          for i in 1...3 {
  
              self.dispatchGroup.enter()
  
              self.loader.fetch(callback: { [weak self] (string) in
  
                  self?.list.append(string)
                  self?.dispatchGroup.leave()
              })
          }
  
          dispatchGroup.notify(queue: .main) {
  
              callback()
          }
      }
  }
  
  PlaygroundPage.current.needsIndefiniteExecution = true
  
  var service = MyService()
  service.loadList {
  
      print("Done is called now!")
  }
  </code></pre>