URLSessionDelegate方法的单元测试-Swift

我有一个名为 CertificatePinningDelegate 的自定义委托类,它符合 URLSessionDelegate 。我正在使用委托方法

urlSession(_ session: URLSession,didReceive challenge: URLAuthenticationChallenge,completionHandler: @escaping (URLSession.AuthChallengeDisposition,URLCredential?) -> Void) 

与服务器进行身份验证。现在,我想为此编写一个单元测试。

我一直在尝试手动调用委托方法来传递自定义的 URLAuthenticationChallenge 对象,这似乎是不可能的。有人知道其他替代/更好的选择吗?

zhaojiejie 回答:URLSessionDelegate方法的单元测试-Swift

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3105069.html

大家都在问