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
| override func setUpWithError() throws { | |
| try super.setUpWithError() | |
| continueAfterFailure = false | |
| self.app = XCUIApplication() | |
| let path = Bundle.allBundles.compactMap { $0.path(forResource: "state", ofType: "json") }.first! | |
| self.app.launchArguments = [ | |
| "-initialScreen", "home_screen", | |
| "-state", path, | |
| "-reset", "true" | |
| ] |
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 testStartingFromHomeScreen() { | |
| self.app.launch() | |
| let homeView = self.app.otherElements[HomeView.AccessibilityIdentifiers.homeView.rawValue] | |
| XCTAssertTrue(homeView.exists) | |
| XCTAssertEqual(self.app.staticTexts[HomeView.AccessibilityIdentifiers.name.rawValue].label, "Riccardo") | |
| XCTAssertEqual(self.app.staticTexts[HomeView.AccessibilityIdentifiers.surname.rawValue].label, "Cipolleschi") | |
| XCTAssertEqual(self.app.staticTexts[HomeView.AccessibilityIdentifiers.age.rawValue].label, "32") | |
| XCTAssertEqual(self.app.staticTexts[HomeView.AccessibilityIdentifiers.coins.rawValue].label, "0") | |
| XCTAssertTrue(self.app.buttons[HomeView.AccessibilityIdentifiers.purchase.rawValue].exists) |
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
| // Entry point of the app | |
| func scene( | |
| _ scene: UIScene, | |
| willConnectTo session: UISceneSession, | |
| options connectionOptions: UIScene.ConnectionOptions | |
| ) { | |
| // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. | |
| // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. | |
| // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). | |
| guard let scene = (scene as? UIWindowScene) else { return } |
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 extractState() -> Models.User? { | |
| guard | |
| let state = UserDefaults.standard.string(forKey: "state"), | |
| let fileContent = try? String(contentsOfFile: state), | |
| let fileData = fileContent.data(using: .utf8) | |
| else { | |
| return nil | |
| } | |
| return try? JSONDecoder().decode(Models.User.self, from: fileData) |
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 path = Bundle | |
| .allBundles | |
| .compactMap { $0.path(forResource: "state", ofType: "json") } | |
| .first! |
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
| { | |
| "name": "Riccardo", | |
| "surname": "Cipolleschi", | |
| "age": 32, | |
| "coins": 0 | |
| } |
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 SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
| func scene( | |
| _ scene: UIScene, | |
| willConnectTo session: UISceneSession, | |
| options connectionOptions: UIScene.ConnectionOptions | |
| ) { | |
| // ... | |
| // create the view controller we need |
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 HomeTests: XCTestCase { | |
| var app: XCUIApplication! | |
| override func setUpWithError() throws { | |
| try super.setUpWithError() | |
| continueAfterFailure = false | |
| self.app = XCUIApplication() | |
| // We are passing the arguments here. |
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 | |
| // ... | |
| } | |
| } |
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 LegalTests: XCTestCase { | |
| var app: XCUIApplication! | |
| var tosButton: XCUIElement! | |
| var privacyButton: XCUIElement! | |
| var continueButton: XCUIElement! | |
| var homeScreen: XCUIElement? | |
| override func setUpWithError() throws { | |
| try super.setUpWithError() |