I have defined my own class with methods that fits signature of URLSession complete callback, e. g. (Data?, Response?, Error?) -> Void
.
The method contains common logic for handling response, e. g. checking data, parsing it etc.
Now I would like to unit test this method. The methods contains some verification, for instance,
guard let data = data else {
//some logic
return
}
Here I would like to test that function will really be terminated. Of course it is not possible to achieve it against void return (I think so, maybe I missed something).
Another option - mark the method as throws
, and then test for a specific errors. But then this method will not fit into URLSession.shared.dataTask
method.
Am I paranoid about these things? Is there any possibility to achieve it?
Thanks in advance.