TDD(1)--轉自http://www.aygfsteel.com/yandazhi
TDD是這樣一種設計風格
Maintain an exhaustive suite of Programmer Tests
維護一套程序員測試的框架
No code goes into production unless it has associated tests
除非它已結合測試,產品不寫入任何代碼
Write the tests first
先寫測試
Tests determine what code you need to write
測試決定你需要寫什么代碼








要通過上面的測試,你必須創建一個類MovieList,和一個方法size();
(eclipse的快速修復功能能幫你搞定哦。看來先寫測試還是很方便的*^^*)
讓計算機來告訴你
你需要增加類或者方法,編譯器會告訴你。(eclipse會向你抱怨有cannot be resolved 的)
下面看看代碼的演進

























非常有意思,和我們平時寫代碼的順序相反
下面看看getAverageRating();















































實際上,每次變化之后都重新編譯和運行這個測試。
Agile Modeling and TDD
posted on 2005-07-25 12:26 辰 閱讀(225) 評論(0) 編輯 收藏 所屬分類: Test-Driven Development