Daily iOS
TestingFlipkart

URLProtocol-based mocking

To test the network layer you've decided to intercept responses with a URLProtocol subclass. Which statements are correct? Select all that apply.

final class StubProtocol: URLProtocol {
    static var handler: ((URLRequest) throws -> (HTTPURLResponse, Data))?
    override class func canInit(with request: URLRequest) -> Bool { true }
    override class func canonicalRequest(for request: URLRequest) -> URLRequest { request }
    override func startLoading() { /* ... */ }
    override func stopLoading() {}
}

Pick all that apply

Submit