Is there any way to stub network requests for UITests which are written in Swift?
I’ve already installed OHHTTPStubs pods but couldn’t managed to stub my network requests via using its methods which is because UITest target and application target are executed in different threads.
I’ll appreciate any recommendations.
Stubbing needs to be done in the application under test's code, rather than the test code. This is because the UI testing process does not have any control over the networking of the app under test, since they are separate from each other.
Send a launch argument when you launch the app from your test and read the launch argument in your app to invoke the stubs as part of
application:didFinishLaunchingWithOptions:
in yourAppDelegate
.