URLSessionDelegate 方法的单元测试 - Swift

Shi*_*man 6 xcode unit-testing swift urlsession urlauthenticationchallenges

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

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

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

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