Files
QuizApp/QuizAppUITests/QuizAppUITests.swift
2025-09-10 21:29:44 +02:00

65 lines
2.9 KiB
Swift

//
// QuizAppUITests.swift
// QuizAppUITests
//
// Created by Paul on 02.08.25.
//
import XCTest
final class QuizAppUITests: XCTestCase {
var app: XCUIApplication!
override func setUpWithError() throws {
continueAfterFailure = false
app = XCUIApplication()
app.launch()
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testMultipleChoice() throws {
app/*@START_MENU_TOKEN@*/.buttons.containing(.staticText, identifier: "Hauptstädte").firstMatch/*[[".buttons",".containing(.staticText, identifier: \"Highscore: 7\").firstMatch",".containing(.staticText, identifier: \"Hauptstädte\").firstMatch",".otherElements.buttons[\"Hauptstädte, Highscore: 7\"]",".buttons[\"Hauptstädte, Highscore: 7\"]"],[[[-1,4],[-1,3],[-1,0,1]],[[-1,2],[-1,1]]],[2,0]]@END_MENU_TOKEN@*/.tap()
//Erscheint die erste Frage korrekt?
let q1 = app.staticTexts["Was ist die Hauptstadt von Frankreich?"]
XCTAssertTrue(q1.waitForExistence(timeout: 1))
app.buttons["Paris"].tap()
//Korrekte Auswertung?
XCTAssertTrue(app.staticTexts["✅ Richtig!"].waitForExistence(timeout: 1))
XCTAssertTrue(app.buttons["Nächste Frage"].exists)
}
func testEstimationSliderDisabledAfterSubmit() throws {
app.staticTexts["Schätzen"].tap()
let slider = app.sliders.element(boundBy: 0)
XCTAssertTrue(slider.waitForExistence(timeout: 2))
slider.adjust(toNormalizedSliderPosition: 0.7)
let submit = app.buttons["Antwort abgeben"]
XCTAssertTrue(submit.exists)
submit.tap()
// Slider muss disabled sein
XCTAssertFalse(slider.isEnabled)
XCTAssertTrue(app.buttons["Nächste Frage"].waitForExistence(timeout: 2))
}
func testQuit() throws {
app/*@START_MENU_TOKEN@*/.buttons.containing(.staticText, identifier: "Hauptstädte").firstMatch/*[[".buttons",".containing(.staticText, identifier: \"Highscore: 7\").firstMatch",".containing(.staticText, identifier: \"Hauptstädte\").firstMatch",".otherElements.buttons[\"Hauptstädte, Highscore: 7\"]",".buttons[\"Hauptstädte, Highscore: 7\"]"],[[[-1,4],[-1,3],[-1,0,1]],[[-1,2],[-1,1]]],[2,0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.buttons["Abbrechen"]/*[[".otherElements[\"Abbrechen\"].buttons.firstMatch",".otherElements.buttons[\"Abbrechen\"]",".buttons[\"Abbrechen\"]"],[[[-1,2],[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.buttons["Quiz verlassen"]/*[[".otherElements.buttons[\"Quiz verlassen\"]",".buttons[\"Quiz verlassen\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
let welcome_msg = app.staticTexts["Willkommen!"]
XCTAssertTrue(welcome_msg.waitForExistence(timeout: 1))
}
}