单元测试 UnitTest

一个网络测试例子 (参考AFN项目的测试用例)
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
    
    AFHTTPSessionManager *_mag = [AFHTTPSessionManager manager];
    [_mag
     GET:@"https://api.douban.com/v2/book/1220562" parameters:nil
     progress:nil
     success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        XCTAssertNotNil(responseObject);
         [expectation fulfill];
    }
    failure:nil];
    
    [self waitForExpectationsWithTimeout:3.0 handler:nil];

你可能感兴趣的:(单元测试 UnitTest)