Bootstrap custom version of the app for UI tests

This commit is contained in:
Stefan Ceriu
2022-04-29 10:11:42 +03:00
parent cfd0b14c81
commit 0faac20b04
7 changed files with 114 additions and 22 deletions
+15 -1
View File
@@ -9,9 +9,23 @@
import XCTest
struct Application {
func launch() {
static func launch() -> XCUIApplication {
let app = XCUIApplication()
app.launchEnvironment = ["IS_RUNNING_UI_TESTS": "1"]
app.launch()
return app
}
}
extension XCUIApplication {
func goToScreenWithIdentifier(_ identifier: String) {
let button = self.buttons[identifier]
let lastLabel = staticTexts["lastItem"]
while !button.isHittable && !lastLabel.isHittable {
self.tables.firstMatch.swipeUp()
}
button.tap()
}
}
-12
View File
@@ -1,12 +0,0 @@
//
// ElementXUITests.swift
// ElementXUITests
//
// Created by Stefan Ceriu on 11.02.2022.
//
import XCTest
class ElementXUITests: XCTestCase {
}
+12
View File
@@ -15,3 +15,15 @@
//
import XCTest
class LoginScreenUITests: XCTestCase {
func testInitialStateComponents() {
let app = Application.launch()
app.goToScreenWithIdentifier("Login screen")
XCTAssert(app.staticTexts["Login"].exists)
XCTAssert(app.buttons["Login"].exists)
XCTAssert(app.textFields["Username"].exists)
XCTAssert(app.secureTextFields["Password"].exists)
}
}