You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[x ] I have read the OHHTTPStubs wiki to see if there wasn't a detailed page talking about my issue
Environment
version of OHHTTPStubs: 9.1.0
integration method you are using:
Cocoapods
Carthage
submodule
[ x] other: SPM
version of the tool you use: Xcode 12.5
Issue Description
I am using OHHTTPStubs in my Units tests without any issue.
For my unit tests target I have my main app selected as the host application.
I have OHHTPStubs added under link with libraries for the unit testing target.
For my UITest target I have my main app selected as the target app.
I have also added OHHTPStubs under link with libraries for the UI testing target.
I am able to import OHHTTPStubs in to my UITest files and can add code to stub out requests. But when I run a UITest the stub blocks are never called.
I do not have OHHTTPStubs added under link with libraries for my main app.
Include OHTTPStubs, and sample JSON in my main bundle.
To make sure the sample JSON is not pushed to production I use a different target for production and another one for all other builds. hence all the sample JSON are not a part of production build.
Use environment variable and check for the environment variable if passed then mock the API calls.
The environment variable check code is under IF Debug compiler flag hence that does not ship to production either.
Now this environment variable can be passed in the UI test as launch arguments when launching the application in the UI test.
Hope this helps. Let me know for any more info.
Include OHTTPStubs, and sample JSON in my main bundle.
To make sure the sample JSON is not pushed to production I use a different target for production and another one for all other builds. hence all the sample JSON are not a part of production build.
Use environment variable and check for the environment variable if passed then mock the API calls.
The environment variable check code is under IF Debug compiler flag hence that does not ship to production either.
Now this environment variable can be passed in the UI test as launch arguments when launching the application in the UI test.
Hope this helps. Let me know for any more info.
Hi @kishorepran, so how about my JSON file? All of them put in main bundle? I think it will improve the app's size.
Activity
LemonSpike commentedon Aug 30, 2021
Having the same issue here.
anelrh26 commentedon Oct 7, 2021
having the same issue here. I'm using Xcode 13
kishorepran commentedon Nov 14, 2021
What I have done in my project
Hope this helps. Let me know for any more info.
ppamorim commentedon Sep 27, 2022
Same issue :(
kishorepran commentedon Sep 27, 2022
Can you create a repo for your sample project and share link here. I would love to debug your issue and submit a pr. thanks
Wiley-Wan commentedon Jul 14, 2023
Hi @kishorepran, so how about my JSON file? All of them put in main bundle? I think it will improve the app's size.
kishorepran commentedon Jul 15, 2023
@Wiley-Wan : Please refer to point 2
sulaimankhan7 commentedon Mar 26, 2024
Same. Couldn't use it with my UITest
kishorepran commentedon Mar 29, 2024
Hi @sulaimansust , @Wiley-Wan : Please upload a sample project where this is not working and let me raise a pr with working example.