-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems when declaring stubs in app and in tests #50
Comments
Hi @pbernery This issue was already encountered by someone else and is a tricky case when you mix Application Tests and Unit Tests. See issue #47 for more details where we finally understood what was going on. I was planning on writing a dedicated wiki article to explain this tricky case in details, but haven't got the time to publish it yet. In summary, the problem is that when you run Application Tests, Xcode will launch your application in the simulator (and calling you The consequence it that the Actually, that's generally what you expect, as stubs installed by your Unit Tests should only affect Unit Tests itselves, and stubs installed by your application should only affect your application code and not your test code too. This is all because Xcode loads the application bundle first and the test bundle then separately, as two separate executable bundles. If you don't do any Application Tests (like GUI testing) but only do Unit Tests (like functional tests to test your WebServices and all) that don't need your Application and its UI to be running:
This way your UIApplication won't be launched, its delegate methods won't be called, and you will only have the Unit Test bundle and only one |
Wow, thank you @AliSoftware for this comprehensive answer! :) That's what I had in mind but wanted to be sure before continuing. Unfortunately, my project cannot have his tests executed in "Unit Tests" mode. It uses a library (closed, I don't have the source) that asserts on some things that I guess come with the initialization of an app. I may find a workaround for this issue though. Anyway, thank you again. I guess I can close this issue. |
Hi there Just to let you know I finally written/updated the dedicated wiki article about this issue (at last!) My opinion is that you should simply not link OHHTTPStubs with your test target as it is already linked against your app target and this latter will load/host the test target ultimately. This will prevent the OHHTTPStubs lib to be loaded twice and would avoid such issues. This is also true for any other library linked against both your app and test target when you are doing application tests. |
👍 |
Hi,
I use OHHTTPStubs for two things:
I encounter an issue, demonstrated with the sample available here: OHHTTPStubs seems to not detect the two stubs I declared, one in my app delegate, the other one in my tests. Only one of them is available in the tests while I expect to be able to use both (in my sample project, only the one declared in the tests is available in the tests, while in another project this is the opposite).
I guess I am not using OHHTTP the right way. I would appreciate if you could let me know if I am doing something wrong or if this is an known limitation, or any other thing.
Thanks.
The text was updated successfully, but these errors were encountered: