I once asked a question related to XCTests. And in one of the answers I was told that it is a common practice to use a separate test host (other than the main app) when running unit tests (at least, in iOS development). I tried to find some sources about it, but I couldn't
I understand, that it is probably a best practice, so I would really like to understand it. Could someone explain to me why is it important, what benefits do I get from it and how should I go about doing it? Links to some articles explaining the issue will be much appreciated.
P.S. I understand that I need special environment for tests (fake in-memory database, mocked networking layer, etc.), but up until now I managed to achieve it without a separate test host, using just my main app, like the Xcode suggests by default. But I believe that there might be a better way. And I know that the defaults that Xcode suggests are not always that great.
Reasons to use a different host app for unit tests:
Reason 1 is pretty much a given. But what about reason 2?
My approach is to use the main app, but use a different application delegate during testing. That way I don't have to maintain a separate app, just an alternate start-up process. See How to Easily Switch Your App Delegate for Testing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With