Skip to content

Instantly share code, notes, and snippets.

@dheerajn
Last active September 19, 2021 18:56
Show Gist options
  • Save dheerajn/38678cc8f7748c57e2dd424b49a9d7a9 to your computer and use it in GitHub Desktop.
Save dheerajn/38678cc8f7748c57e2dd424b49a9d7a9 to your computer and use it in GitHub Desktop.
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