Files
QuizApp/QuizAppUITests/QuizAppUITests.swift
2025-09-10 21:42:49 +02:00

65 lines
1.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.buttons.containing(.staticText, identifier: "Hauptstädte").firstMatch.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.buttons.containing(.staticText, identifier: "Hauptstädte").firstMatch.tap()
app.buttons["Abbrechen"].tap()
app.buttons["Quiz verlassen"].tap()
let welcome_msg = app.staticTexts["Willkommen!"]
XCTAssertTrue(welcome_msg.waitForExistence(timeout: 1))
}
}