I am testing an asynchronous call using XCTestExpectation.
The following code works (the test succeeds) when executeHandler is executed before the specified 1 second timeout.
func test__async_call() { // prepare let sut = ClassToTest() let expectation: XCTestExpectation = self.expectationWithDescription(nil) // test sut.methodToTestWithCompletionHandler() { () -> () in expectation.fulfill() } // verify self.waitForExpectationsWithTimeout(1, handler: nil) }
However, if the Handler termination is not called, and therefore the wait is not fulfilled, instead of getting a test failure when calling waitForExpectationsWithTimeout, I get EXC_BAD_ACCESS, which is not very convenient, since it makes it impossible to view the results of the entire test suite.
How can I avoid this and get a normal test failure?
e1985 source share