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 | |
| self.setupAccessibilityIdentifiers() | |
| // ... | |
| } | |
| } |
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
| // In the LegalView.swift | |
| func setup() { | |
| // .. add element to subview | |
| self.tosButton.accessibilityIdentifier = "legal_view.tos_button" | |
| self.privacyButton.accessibilityIdentifier = "legal_view.privacy_button" | |
| self.continueButton.accessibilityIdentifier = "legal_view.continue_button" | |
| } | |
| // --- | |
| // In the UITest | |
| func test() { |
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
| func testExample() throws { | |
| // UI tests must launch the application that they test. | |
| let app = XCUIApplication() | |
| app.launch() | |
| // Use recording to get started writing UI tests. | |
| // Use XCTAssert and related functions to verify your tests produce the correct results. | |
| let tosButton = app.buttons["legal_view.tos_button"] | |
| let privacyButton = app.buttons["legal_view.privacy_button"] |
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
| private func setup() { | |
| // ... other view elements ... | |
| self.addSubview(tosButton) | |
| self.addSubview(privacyButton) | |
| self.addSubview(continueButton) | |
| // Add these lines to let the XCUITest access the buttons with identifiers | |
| self.tosButton.accessibilityIdentifier = "legal_view.tos_button" | |
| self.privacyButton.accessibilityIdentifier = "legal_view.privacy_button" | |
| self.continueButton.accessibilityIdentifier = "legal_view.continue_button" |
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
| let tosButton = app.staticTexts["Tap to accept TOS"] | |
| let privacyButton = app.staticTexts["Tap to Accept Privacy Policy"] | |
| let continueButton = app.staticTexts["Continue"] | |
| XCTAssertFalse(tosButton.isSelected) | |
| XCTAssertFalse(privacyButton.isSelected) | |
| XCTAssertFalse(continueButton.isEnabled) | |
| tosButton.tap() |
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
| func testExample() throws { | |
| // UI tests must launch the application that they test. | |
| let app = XCUIApplication() | |
| app.launch() | |
| // Use recording to get started writing UI tests. | |
| // Use XCTAssert and related functions to verify your tests produce the correct results. | |
| // XCODE STARTS WRITING HERE:👇 | |
| let app = XCUIApplication() |
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
| import XCTest | |
| class UITestAppUITests: XCTestCase { | |
| override func setUpWithError() throws { | |
| // Put setup code here. This method is called before the invocation of each test method in the class. | |
| // In UI tests it is usually best to stop immediately when a failure occurs. | |
| continueAfterFailure = false |
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
| import Foundation | |
| do { | |
| let version = try String(contentsOfFile: ".version") | |
| .trimmingCharacters(in: CharacterSet.init(charactersIn: " \n")) | |
| print(version) | |
| } catch { | |
| print("[ERROR] Unable to read file .version.\nError: \(error.localizedDescription)") | |
| } |
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
| import Foundation | |
| print("Hello, World!") |
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
| // Data structure for a Movie | |
| struct Movie: Codable { | |
| let id: String | |
| let title: String | |
| let description: String | |
| let director: String | |
| let producer: String | |
| let releaseDate: String | |
| let rtScore: String | |
| let url: URL |