Closed szymon-kazmierczak closed 6 years ago
Hello
Yes it is totally possible.
Either by using a fallback stub, as explained in the wiki here…
Or better, since the last version (6.1.0) there's even a dedicated method for that now, called onStubMissing
. You can call it in the setup
of your tests to tell what to do if a network request which is not subbed is encountered, so you can for example log a message, make your test fail, or fatalError, or make the request return an HTTP error for those unstubbed requests, etc.
New Issue Checklist
OHHTTPStubs
for your project sectionEnvironment
Issue Description
Is it possible to disable network calls if they are not mocked? I want to make sure that my test suite does not perform any network call that is not mocked - ideally log the cases where the mock is missing, with some additional info like URL.
In another project I'm working on (Android app, using RESTMock, the mocking solution has its own IP/port (localhost and an empty port) and it intercepts all the calls being made and notifies the user when a mock is missing.