Testing in Swift
hugo
4/25/2015
軟體開發有三種⽅方式
藝⾼高⼈人膽⼤大
圖⽚片出處 http://goo.gl/fqvzJv
不敢玩真的
圖⽚片出處http://goo.gl/gWI6cY
安全的冒險
圖⽚片出處 http://goo.gl/sp3GPT
單元測試的三個步驟
設定Target Membership
產⽣生測試檔
測試 vs 實做
測試驅動開發三階段
Test Driven Development
紅燈:寫出失敗的測試
Build: ⌘B
Test: ⌘U
Run: ⌘R
綠燈:讓測試通過
重構:改善既有程式
圖⽚片出處 http://goo.gl/Njgoe6
TDD的理由
• 簡單設計
• 沒有 dead code
• 從使⽤用者⾓角度設計
• 測試涵蓋率⾼高
• 容易維護與重構
• 擁有可執⾏行的⽂文件 圖⽚片出處 http://goo.gl/R5aD5X
參考資料
• How to write unit tests in Swift with XCTest

http://roadfiresoftware.com/2014/06/unit-testing-
with-swift/
• Test Driven Development

http://devmonologue.com/ios/category/test-driven-
development/
• TDD for iOS in Swift – What’s the Goal?

http://www.andrewcbancroft.com/2014/12/16/tdd-
ios-swift-whats-goal/

Testing in swift