How to detect if iOS app is running in UI Testing mode

前端 未结 7 1442
抹茶落季
抹茶落季 2020-12-05 01:46

I would like my app to run special code (e.g. resetting its state) when running in UI Testing mode. I looked at environment variables that are set when the app is running fr

7条回答
  •  一个人的身影
    2020-12-05 02:19

    In Swift 3 you can check for the XCInjectBundleInto key, or something that starts with XC.

    let isInTestMode = ProcessInfo.processInfo.environment["XCInjectBundleInto"] != nil
    

    This works in OS X as well.

提交回复
热议问题