iOS單元測試中測試異步方法

- (void)testAsync {

    //設置預期
    XCTestExpectation *expactation = [self expectationWithDescription:@"異步測試"];
    [Person loadPersonAsync:^(Person *person) {
        NSLog(@"%@",person);
        //預期達成
        [expactation fulfill];
    }];
    //預期超時等待
    [self waitForExpectationsWithTimeout:10 handler:nil];
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章