Sunday, July 12, 2009

軟體測試的藝術

線上翻譯:http://sun.cis.scu.edu.tw/~nms9115/articles/testing/
Testing Principles《測試原則》
  1. A necessary part of a test case is a definition of the expected output or result. 每個測試案例中必須定義期望輸出值或結果
  2. A programmer should avoid attempting to test his or her own program. 程式設計師應避免測試他/她自己的程序
  3. A programming organization should not test its own programs. 程式設計團隊應避免測試它自己的程序
  4. Thoroughly inspect the results of each test. 仔細檢查每一項測試結果
  5. Test cases must be written for input conditions that are invalid and unexpected, as well as for those that are valid and expected. 設計測試樣本時,不合理、不被預期的輸入情況,與合理、被預期的輸入情況同樣重要
  6. Examining a program to see if it does not do what it is supposed to do is only half the battle; the other half is seeing whether the program does what it is not supposed to do. 不要只看看程式是否做了它該做的事,更要看看程式是否做了它不該做的事
  7. Avoid throwaway test cases unless the program is truly a throwaway program. 除非你要丟棄程式,否則這個程式使用過的測試樣本不要丟棄
  8. Do not plan a testing effort under the tacit assumption that no errors will be found. 不要基於程式沒有錯誤的假設來做測試
  9. The probability of the existence of more errors in a section of a program is proportional to the number of errors already found in that section. 還存在於程式裡的錯誤和已發現的錯誤數目成正比
  10. Testing is an extremely creative and intellectually challenging task. 測試是一項極具創造性和智力挑戰的任務
以上是節錄二十年前的Myers所定義的軟體測試原則,二十年後的今天似乎都還是依然適用。不過第2, 3點好像和最近的Agile Methodology倡導的UnitTest有所衝突,究竟在實務上要如何在兩者之間抉擇呢?

No comments: