Xcode 7.3b3 (7D141l): Add a way to tell if you're in a logic or UI test

Originator:igeek1
Number:rdar://24686001 Date Originated:16-Feb-2016 06:01 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7.3b3 (7D141l)
Classification:Enhancement Reproducible:Always
 
Summary:
There is no easy way to detect if you are inside a test without resorting to launch arguments and other trickery.

Steps to Reproduce:
1. Find that some code needs to behave differently in a testing environment.
2. Attempt to wrap that code in a conditional check for logic or UI tests.

Expected Results:
There is an easy way to do this, such as a property on NSProcessInfo that tells you whether you’re in an app-hosted test, logic test, UI test, or not testing, perhaps using an enum.

Actual Results:
There is no easy way to do it. You have to resort to a combination of (NSClassFromString(“XCTestCase”) != nil), launch argument hackery, and witchcraft.

Regression:
-

Notes:
-

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!