Mocker
public struct Mocker
Can be used for registering Mocked data, returned by the MockingURLProtocol
.
-
The HTTP Version to use in the mocked response.
Declaration
Swift
public static var httpVersion: HTTPVersion = HTTPVersion.http1_1
-
Register new Mocked data. If a mock for the same URL and HTTPMethod exists, it will be overwritten.
Declaration
Swift
public static func register(_ mock: Mock)
Parameters
mock
The Mock to be registered for future requests.
-
Retrieve a Mock for the given request. Matches on
request.url
andrequest.httpMethod
.Declaration
Swift
public static func mock(for request: URLRequest) -> Mock?
Parameters
request
The request to search for a mock.
Return Value
A mock if found,
nil
if there’s no mocked data registered for the given request.