Why should I use a separate test host for running XCTests and how should I do that?

后端 未结 1 1467
南方客
南方客 2021-01-13 04:29

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 runn

相关标签:
1条回答
  • 2021-01-13 05:00

    Reasons to use a different host app for unit tests:

    1. There is no main app, because your target is a library.
    2. When the main app is launched, it goes through its start-up process. This takes too long, and has side-effects.

    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

    0 讨论(0)
提交回复
热议问题