TodoList_StoryboardUITests.swift
iOS_App/TodoList-Storyboard/TodoList-StoryboardUITests/TodoList_StoryboardUITests.swift
//
// TodoList_StoryboardUITests.swift
// TodoList-StoryboardUITests
//
// Created by Nelson Lai on 2026/7/15.
//
import XCTest
final class TodoList_StoryboardUITests: XCTestCase {
override func setUpWithError() throws {
continueAfterFailure = false
}
/// 完整流程測試:新增兩筆待辦事項,並將其中一筆標記為完成
@MainActor
func testAddAndCompleteTodoItems() throws {
let app = XCUIApplication()
app.launch()
// 新增第一筆:買牛奶
app.navigationBars.buttons["Add"].tap()
let textField = app.alerts.textFields.firstMatch
XCTAssertTrue(textField.waitForExistence(timeout: 3))
textField.typeText("買牛奶")
app.alerts.buttons["新增"].tap()
// 新增第二筆:寫 iOS 作業
app.navigationBars.buttons["Add"].tap()
XCTAssertTrue(textField.waitForExistence(timeout: 3))
textField.typeText("寫 iOS 作業")
app.alerts.buttons["新增"].tap()
// 確認兩筆都出現在列表上
XCTAssertTrue(app.staticTexts["買牛奶"].waitForExistence(timeout: 3))
XCTAssertTrue(app.staticTexts["寫 iOS 作業"].exists)
// 點擊「買牛奶」把它標記為已完成
app.staticTexts["買牛奶"].tap()
// 等待畫面更新
sleep(1)
}
}
相關文章
AddItemView.swift
AddItemView.swift — swift source code from the iOS App learning materials (iOS_App/To-Do-List-Demo/To-Do-List-Demo/AddItemView.swift).
閱讀文章 →ContentView.swift
ContentView.swift — swift source code from the iOS App learning materials (iOS_App/To-Do-List-Demo/To-Do-List-Demo/ContentView.swift).
閱讀文章 →Item.swift
Item.swift — swift source code from the iOS App learning materials (iOS_App/To-Do-List-Demo/To-Do-List-Demo/Item.swift).
閱讀文章 →ItemDetailView.swift
ItemDetailView.swift — swift source code from the iOS App learning materials (iOS_App/To-Do-List-Demo/To-Do-List-Demo/ItemDetailView.swift).
閱讀文章 →To_Do_List_DemoApp.swift
To_Do_List_DemoApp.swift — swift source code from the iOS App learning materials (iOS_App/To-Do-List-Demo/To-Do-List-Demo/To_Do_List_DemoApp.swift).
閱讀文章 →To_Do_List_DemoTests.swift
To_Do_List_DemoTests.swift — swift source code from the iOS App learning materials (iOS_App/To-Do-List-Demo/To-Do-List-DemoTests/To_Do_List_DemoTests.swift).
閱讀文章 →