/networking-tests-swift

Sample application on how to test networking in Swift

Primary LanguageSwiftApache License 2.0Apache-2.0

networking-tests-swift

Sample application on how to test networking in Swift.

Examples are provided in NetworkTestingTests target.

Using shared URLSession

Just register your custom URLProtocol subclass on application startup:

URLProtocol.registerClass(URLProtocolMock.self)

Using custom URLSession

Add your custom URLProtocol subclass to protocolClasses property of URLSessionConfiguration:

let configuration = URLSessionConfiguration.default
configuration.protocolClasses = [URLProtocolMock.self]

let session = URLSession(configuration: configuration)