【发布时间】:2014-08-30 13:04:07
【问题描述】:
我已经开始探索用于异步和性能测试的新 XCTest API。单独来看,WWMC 中的 Apple 示例运行良好,但我一直无法弄清楚如何将它们结合起来。我能想到的最好的方法如下,但运行时我收到以下错误:
API 违规 - 在未设置任何期望的情况下调用等待。
XCTestExpectation *clsQueryReturnedExpectation = [self expectationWithDescription:@"clsQuery returned"];
PFCLSClient *theClient = [[PFCLSClient alloc] init];
[self measureMetrics:@[XCTPerformanceMetric_WallClockTime] automaticallyStartMeasuring:YES forBlock: ^{
[theClient getStructureOfType:clsImageTypeSVG ForID:idString success: ^(NSDictionary *structureInfo) {
[clsQueryReturnedExpectation fulfill];
} failure: ^(NSError *error) {
XCTFail();
[clsQueryReturnedExpectation fulfill];
}];
[self waitForExpectationsWithTimeout:5 handler: ^(NSError *error) {
[self stopMeasuring];
}];
}];
有没有人能够完成类似的事情?
谢谢
【问题讨论】:
标签: ios unit-testing asynchronous xctest