Open ghost opened 5 years ago
Hey @Shanakor ! I'm not exactly sure what you're asking for here. Can you please clarify what you need? This library already uses method swizzling.
I was referring to the "Known Limitations" section in the readme.md (https://github.com/AliSoftware/OHHTTPStubs#known-limitations).
It states that OHHTTPStubs is unable to handle upload requests.
OHHTTPStubs don't simulate data upload. The NSURLProtocolClient @protocol does not provide a way to signal the delegate that data has been sent (only that some has been loaded), so any data in the HTTPBody or HTTPBodyStream of an NSURLRequest, or data provided to -[NSURLSession uploadTaskWithRequest:fromData:]; will be ignored, and more importantly, the -URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend: delegate method will never be called when you stub the request using OHHTTPStubs
and
As far as I know, there's nothing we can do about those three limitations. Please let me know if you know a solution that would make that possible anyway.
So, why do you not simply swizzle the methods of classes like NSURLConnection
like in the stackoverflow link I posted?
We also faced the issue with using OHHTTPStubs in out project. We failed to mock the upload request (it hags out until it times out and only then returns mocked data). Looking for a solution for that.
If it is possible with OHHTTPStubs, would appreciate some help
I have been able to implement mock tests for my upload requests based on this Stackoverflow answer.
As a result, I have removed every
OHHttpStubs
dependency from my project, to not mix libraries. Maybe you could change your internal approach to stubbing the web requests and support upload tasks as well, based onOCMock
?If you do not want to depend on an external library, I think you could implement similar behaviour as
OCMock
with Method Swizzling.