使用XCTest进行异步性能测试
我已经开始探索用于异步和性能测试的新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]; }]; }];
有没有人能够完成类似的事情?
谢谢
在Apple的帮助下,我有了解决方案。 对我来说是愚蠢的疏忽,因为这很容易解决。 要开始工作,您需要做的就是在expectMetrics块中创建期望对象(clsQueryReturnedExpectation),以便每次运行性能测试时重新创建它。
PFCLSClient *theClient = [[PFCLSClient alloc] init]; [self measureMetrics:@[XCTPerformanceMetric_WallClockTime] automaticallyStartMeasuring:YES forBlock: ^{ XCTestExpectation *clsQueryReturnedExpectation = [self expectationWithDescription:@"clsQuery returned"]; [theClient getStructureOfType:clsImageTypeSVG ForID:idString success: ^(NSDictionary *structureInfo) { [clsQueryReturnedExpectation fulfill]; } failure: ^(NSError *error) { XCTFail(); [clsQueryReturnedExpectation fulfill]; }]; [self waitForExpectationsWithTimeout:5 handler: ^(NSError *error) { [self stopMeasuring]; }]; }];
- beginReceivingRemoteControlEvents不触发Apple Music的事件
- 应用程序启动后,由于正在input受监视的区域而使用Flurrylogging事件
- 在.h中实现一个快速协议是否有可能使用Objective-C类
- 在代码中设置的约束不会反映在输出(Autolayout iOS)
- 如果(设备== iPad),如果(设备== iPhone)
- 如何将多个观察者绑定到一个ControlProperty
- 如何使用CoreAudio的AudioConverter实时编码AAC?
- 如何将UIAppearance Proxy属性应用于UILabel?
- 使用Xcode配置在同一设备上运行您的App的多个版本