Ios 异步等待失败的swift API请求

Ios 异步等待失败的swift API请求,ios,swift,asynchronous,xctest,Ios,Swift,Asynchronous,Xctest,我已经创建了一个单元测试用例来测试我处理API请求的函数 下面我提到了XC测试用例代码 var expectation:XCTestExpectation? func testRequestFunction () { expectation = self.expectationWithDescription("asynchronous request") let test = HVRequest.init(subdomain: "staging", token: "jijf

我已经创建了一个单元测试用例来测试我处理API请求的函数

下面我提到了XC测试用例代码

var expectation:XCTestExpectation?

func testRequestFunction () {

    expectation = self.expectationWithDescription("asynchronous request")

    let test = HVRequest.init(subdomain: "staging", token: "jijfio88fhu0387fh", type: .GET, command: "estm") {
        (success) -> Void in

        }
    test.request()

    self.waitForExpectationsWithTimeout(30, handler: nil)

}
当我运行这个测试用例时,它给出了一个错误

异步等待失败:超过30秒的超时时间,未实现预期:异步请求

它如何显示带有错误的响应JSON对象

请帮助我解决问题

XTestExpection正在等待。当你得到回应时,你必须履行你的意思是:带着期望说我得到回应,继续

    let test = HVRequest.init(subdomain: "staging", token: "jijfio88fhu0387fh", type: .GET, command: "estm") {
        (success) -> Void in
            expectation.fulfill() // add this line
        }
    test.request()
XTestExpection正在等待。当你得到回应时,你必须履行你的意思是:带着期望说我得到回应,继续

    let test = HVRequest.init(subdomain: "staging", token: "jijfio88fhu0387fh", type: .GET, command: "estm") {
        (success) -> Void in
            expectation.fulfill() // add this line
        }
    test.request()

@我已经添加了您推荐的内容。在那之后,它说超过了30秒的超时时间,没有完成expectations@DimuthLasantha您应该添加一个断点,并查看是否调用了fully行。如果没有,您应该编写代码,例如:HVRequest@anthu我已经添加了您推荐的内容。在那之后,它说超过了30秒的超时时间,没有完成expectations@DimuthLasantha您应该添加一个断点,并查看是否调用了fully行。如果没有,您应该编写代码,例如:HVRequest