ios - How to let the app know if its running Unit tests in a pure Swift project? -
one annoying thing when running tests in xcode 6.1 entire app has run , launch storyboard , root viewcontroller. in app runs server calls fetches api data. however, don't want app when running tests.
with preprocessor macros gone, whats best project aware launched running tests , not ordinary launch? run them cmd+u , on bot.
pseudo code be:
// appdelegate.swift if runningtests() { return } else { // ordinary api calls }
instead of checking if tests running avoid side-effects, run tests without host app itself. go project settings -> select test target -> general -> testing -> host application -> select 'none'. remember include files need run tests, libraries included host app target.
Comments
Post a Comment