Tag: xctestexpectation

XCTest:在iOS中XCTestExpectations崩溃

当我运行我的unit testing脚本时,它在“ServiceTest”类中​​的“”waitForExpectationWithTimeout“崩溃。 如果我单独为这个“ServiceTest”类运行testing脚本,那么它运行正常,不会崩溃。 但是,如果我运行整个项目的testing脚本,我正在得到这个崩溃。 我无能为力,这是什么意思呢? 感谢任何帮助。 谢谢。

XCTestCase waitForExpectationsWithTimeout:处理程序:在未满足期望时抛出EXC_BAD_ACCESS

我正在使用XCTestExpectationtestingasynchronous调用。 在给定的1秒超时之前执行completionHandler时,以下代码工作(testing成功)。 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) } 然而,如果completionHandler没有被调用,所以期望没有被满足,而不是在调用waitForExpectationsWithTimeout时得到一个testing失败,我得到一个EXC_BAD_ACCESS,这是不是很方便,因为这使得不可能看到整个testing套件的结果。 我怎样才能避免这种情况,并得到正常的testing失败?