Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 为什么Alamofire在单元测试上使用30秒的超时预期?_Swift_Unit Testing_Alamofire - Fatal编程技术网

Swift 为什么Alamofire在单元测试上使用30秒的超时预期?

Swift 为什么Alamofire在单元测试上使用30秒的超时预期?,swift,unit-testing,alamofire,Swift,Unit Testing,Alamofire,我正在研究Alamofire如何为NSOperations执行单元测试。这是其他测试使用的基本测试类。你知道为什么它要用30秒作为超时的期望值吗 import Alamofire import Foundation import XCTest class BaseTestCase: XCTestCase { let timeout: NSTimeInterval = 30.0 func URLForResource(fileName: String, withExtensio

我正在研究
Alamofire
如何为
NSOperation
s执行单元测试。这是其他测试使用的基本测试类。你知道为什么它要用
30
秒作为
超时
的期望值吗

import Alamofire
import Foundation
import XCTest

class BaseTestCase: XCTestCase {
    let timeout: NSTimeInterval = 30.0

    func URLForResource(fileName: String, withExtension: String) -> NSURL {
        let bundle = NSBundle(forClass: BaseTestCase.self)
        return bundle.URLForResource(fileName, withExtension: withExtension)!
    }
}

我们使用30秒作为标准超时时间。现在,这比您在本地运行时所需的时间要长得多,但在诸如Travis CI之类的CI环境中,运行速度总是较慢。因此,我们提高了默认超时时间,以便让较慢的机器有更多的时间来处理测试。

感谢您的回复。我问了这个问题,因为我试图对Circle CI中的自定义
NSOperation
进行单元测试,但我遇到了超时问题。明白了。我先把暂停时间调高,看看你会怎么做。谢谢。因此,问题可能是由于Circle CI中的资源较低(与本地CI相比)。是的,这是最常见的问题。分布式环境的运行方式与本地测试套件大不相同。