Created
August 9, 2020 10:46
-
-
Save cipolleschi/4c29cd2ffde9ab4a731e62bf3edd93c5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 LegalView: UIView { | |
| func setup() { | |
| // add elements to the view | |
| #if UITESTING | |
| self.setupAccessibilityIdentifiers() | |
| #endif | |
| // ... | |
| } | |
| } | |
| #if UITESTING | |
| extension LegalView { | |
| enum AccessibilityIdentifiers: String { | |
| case legalView = "legal_view" | |
| case tosButton = "legal_view.tos_button" | |
| case privacyButton = "legal_view.privacy_button" | |
| case continueButton = "legal_view.continue_button" | |
| } | |
| func setAcceccibilityIdentifiers() { | |
| self.accessibilityIdentifier = AccessibilityIdentifiers.legalView.rawValue | |
| self.tosButton.accessibilityIdentifier = AccessibilityIdentifiers.tosButton.rawValue | |
| self.privacyButton.accessibilityIdentifier = AccessibilityIdentifiers.privacyButton.rawValue | |
| self.continueButton.accessibilityIdentifier = AccessibilityIdentifiers.continueButton.rawValue | |
| } | |
| } | |
| #endif | |
| // ... and, in the UITest | |
| class LegalTests: XCTestCase { | |
| var app: XCUIApplication! | |
| var tosButton: XCUIElement! | |
| var privacyButton: XCUIElement! | |
| var continueButton: XCUIElement! | |
| var homeScreen: XCUIElement? | |
| override func setUpWithError() throws { | |
| try super.setUpWithError() | |
| continueAfterFailure = false | |
| self.app = XCUIApplication() | |
| self.app.launch() | |
| #if UITESTING | |
| self.tosButton = app.buttons[LegalView.AccessibilityIdentifiers.tosButton.rawValue] | |
| self.privacyButton = app.buttons[LegalView.AccessibilityIdentifiers.privacyButton.rawValue] | |
| self.continueButton = app.buttons[LegalView.AccessibilityIdentifiers.continueButton.rawValue] | |
| #endif | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment