     var exitStatus: Int32?
     var printHistory: [[Any]] = []
     let spinMainQueue = NSThread.sleepForTimeInterval
+    var expectation: XCTestExpectation?
 
     // MARK: - Mocking
 
     @noreturn private func mockExit(status: Int32) {
         exitStatus = status
         callCount++
+        expectation?.fulfill()
         repeat { NSRunLoop.currentRunLoop().run() } while (true)
     }
 


    func testThatItCallsDie() {
        // when
        dispatch(die)
        spinMainQueue(1)

        // then
        XCTAssertEqual(callCount, 1)


    func testThatItCallsDieOnThrow() {
        // when
        dispatchAndWaitForDie(timeout: 2) {
            dieOnThrow {
                throw "Error"
            }
        }

        // then
        XCTAssertEqual(callCount, 1)
