Last active
September 19, 2021 18:56
-
-
Save dheerajn/38678cc8f7748c57e2dd424b49a9d7a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestDetector { | |
private enum Keys: String { | |
case shouldOverrideTitleText = "Override-Label-titleText" | |
case showView2 = "Override-showView2" | |
} | |
static func isRunningUITests() -> Bool { | |
return ProcessInfo.processInfo.arguments.contains("isRunningUITests") | |
} | |
private static func environmentVariable(for key: Keys) -> String? { | |
return ProcessInfo.processInfo.environment[key.rawValue] | |
} | |
static func shouldOverrideTitleText() -> Bool { | |
guard isRunningUITests() else { return false } | |
return Bool(environmentVariable(for: .shouldOverrideTitleText) ?? "") ?? false | |
} | |
static func shouldShowView2() -> Bool { | |
guard isRunningUITests() else { return false } | |
return Bool(environmentVariable(for: .showView2) ?? "") ?? false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment