????????????????????????????????????
?????????????????????У?????????????????????У?????????????????????????????
????????????ж????????е?????????
?????????????????????????????????????????????????????????????????????????У?У?鷵??????
????Demo ?????????????????????
????1?????????XCTestExpectation????
????2????????XCTestExpectation??????????????????????????????????????????????
????3?????????????????
????4???????????????
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "NSObject+YPApiService.h"
#import "YPApiServiceKit.h"
@interface YouPiaoTests : XCTestCase<YPApiServiceKitDataSource>
@property (nonatomic??strong) XCTestExpectation *e;
@end
@implementation YouPiaoTests
- (void) testIndexList {
// 1 ????XCTestExpectation????
XCTestExpectation *e = [self expectationWithDescription:@"des"];
// 2 ???????????
self.e = e;
// 3 ????????????
[self api_Post_IndexList];
// 4 ??? XCTestExpectation??????fulfill?????????????????????
[self waitForExpectationsWithTimeout:10 handler:^(NSError * _Nullable error) {
NSLog(@"%@"??error);
}];
}
// ??????????????????????
- (void)serverResponseSuccess:(YPBaseModel *)responseModel {
NSLog(@"%@"??responseModel);
[self.e fulfill];
}
@end
??????????
??????????????????????????
????????
????self expectationForNotification:@"RSBaseTest" object:nil handler:nil];
??????????
????[self waitForExpectationsWithTimeout:30 handler:nil];} while (0);
??????????
????[[NSNotificationCenter defaultCenter]postNotificationName:@"RSBaseTest" object:nil];