大佬教程收集整理的这篇文章主要介绍了ios – 如何在Obj C中编写没有完成块的异步方法的单元测试,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
-(void) methodToBeTested{ [self callAPIWithCompletionHandler:^(NSArray *data,NSError *error) { //Here I get the response and sets the models. }]; }
现在我需要在API调用之后测试模型集的方法“methodToBeTested”.
有什么建议?
XCTestExpectation *documentOpenExpectation = [self expectationWithDescription:@"document open"]; NSURL *URL = [[NSBundle bundleForClass:[self class]] URLForresource:@"TestDocument" withExtension:@"mydoc"]; UIDocument *doc = [[UIDocument alloc] initWithFileURL:URL]; [doc openWithCompletionHandler:^(BOOL success) { XCTAssert(success); [documentOpenExpectation fulfill]; }]; [self waitForExpectationsWithTimeout:1 handler:^(NSError *error) { [doc closeWithCompletionHandler:nil]; }]; }
查看使用Xcode文档测试下的异步操作的编写测试. https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/04-writing_tests.html
以上是大佬教程为你收集整理的ios – 如何在Obj C中编写没有完成块的异步方法的单元测试全部内容,希望文章能够帮你解决ios – 如何在Obj C中编写没有完成块的异步方法的单元测试所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。