✅Testing System
附錄 ⟩ Testing System
XCTest:Swift 和 Objective-C 專案中常用的單元測試框架。
Swift Testing:現代化測試框架,Swift Package Manager 推薦選項。

structure for a test case:
Arrange: arrange the "system under test" (SUT) and the "inputs".
Act: act on the SUT to get the "output".
Assert: assert the "output" matches the "expected result".
func testEmptyMenuReturnsEmptySections() {
// ⭐️ Arrange: (arrange inputs)
let menu = [MenuItem]()
// ⭐️ Act: (generate output)
let sections = menu.groupedByCategory()
// ⭐️ Assert: (assert match)
XCTAssertTrue(sections.isEmpty)
}Test-Driven Development in Swift (2021)
Last updated
Was this helpful?