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.

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

          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 閱讀(477) 評論(0)  編輯  收藏 所屬分類: Java

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

          導航

          統(tǒng)計

          公告

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

          留言簿(9)

          隨筆分類(68)

          隨筆檔案(80)

          文章分類(1)

          My Open Source Projects

          搜索

          積分與排名

          最新評論

          主站蜘蛛池模板: 亚东县| 张家口市| 仁布县| 济阳县| 贞丰县| 海宁市| 隆化县| 崇仁县| 新丰县| 富顺县| 昌宁县| 肃南| 敖汉旗| 东台市| 将乐县| 贵溪市| 营口市| 乡宁县| 汽车| 玛多县| 紫阳县| 桑植县| 高安市| 廊坊市| 普洱| 吉水县| 阿拉尔市| 沈丘县| 错那县| 定远县| 金塔县| 繁峙县| 修武县| 中西区| 哈尔滨市| 仙游县| 文登市| 资中县| 都匀市| 哈密市| 丰台区|