gr8vyguy@Blogjava

          Automated Unit Test

          The TDD cycle looks like this:

          1. Write a test for the next bit of functionality you have in mind. The test should succeed only when the functionality has been implemented correctly.

          2. Make the test compile by creating stubs for all the missing classes and methods referenced by the test.

          3. Run the test. It should fail.

          4. Implement just enough functionality to get the test to succeed.

          5. Clean up the implementation as much as possible, typically by removing duplication.

          這里最難的是第一點的第二句,"只有正確的程序才能通過測試"。 這幾乎是不可能的,即使可能,所耗的時間也不亞于編寫代碼的時間. 第四點的提法更有問題,程序員在編程實現功能的時候應該把注意力集中在所實現的代碼,而不是測試上。

          The Test/Code Cycle in XP

          • Write one test.
          • Compile the test. It should fail, as you haven't implemented anything yet.
          • Implement just enough to compile. (Refactor first if necessary.)
          • Run the test and see it fail.
          • Implement just enough to make the test pass.
          • Run the test and see it pass.
          • Refactor for clarity and "once and only once".
          • Repeat from the top.


           

          posted on 2007-04-21 23:33 gr8vyguy 閱讀(478) 評論(0)  編輯  收藏 所屬分類: Java

          <2007年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導航

          統計

          公告

        1. 轉載請注明出處.
        2. msn: gr8vyguy at live.com
        3. 常用鏈接

          留言簿(9)

          隨筆分類(68)

          隨筆檔案(80)

          文章分類(1)

          My Open Source Projects

          搜索

          積分與排名

          最新評論

          主站蜘蛛池模板: 商洛市| 通许县| 彰化县| 休宁县| 九江县| 桃园县| 裕民县| 宝兴县| 长泰县| 宜丰县| 五莲县| 东安县| 福贡县| 肃北| 东宁县| 西丰县| 靖江市| 鄱阳县| 保德县| 隆化县| 都江堰市| 乃东县| 九江县| 基隆市| 冷水江市| 德化县| 公主岭市| 英吉沙县| 顺昌县| 威信县| 嘉祥县| 区。| 深圳市| 抚顺县| 始兴县| 清水县| 托克逊县| 沁水县| 平乡县| 台中县| 合水县|