如何設計一個好的測試用例

一,檢查標準

1.準確性(Accurate)

Tests what the descrīption says it will test. 測試覆蓋了描述部分需要測試的內容。

 

2.經濟性(Economical)

Has only the steps needed for its purpose.測試用例沒有冗餘的步驟

 

3.可重複性(Repeatable)

Self standing, same results no matter who tests it.測試用例應該是獨立一致的,不管任何人執行,結果都一致。

 

4.可追蹤(Traceable)

To a requirement.測試用例應該追溯到具體需求。

 

5.自我清理(Self cleaning)

Returns the test environment to clean state.測試結束後,恢復到原有乾淨的狀態,不應該對原有系統造成影響。

 

6. 結構化和可測試性(Structure and testability)

測試用例應該是結構化。一般可以根據一個橫向維度,對測試用例進行功能模塊的劃分;同時縱向維度上可以根據測試類別對測試用例進行縱向結構的劃分。

測試同時應該是可測試性的。對於無法執行的測試用例是沒有意義的。

 

7. 規範性

Has a name and a number. 命名 + 編號

Has a stated purpose that includes what requirement is being tested。目的

Has a descrīption of the method of testing。測試方法

Specifies setup information - environment, data, prerequisite tests, security access。環境, 數據, 前提,權限。

Has actions and expected results。步驟, 期望結果。

States if any proofs, such as reports or screen grabs, need to be saved。

Leaves the testing environment clean。清理數據,還原系統。

這裏其實包含一個測試用例的組成部分:

  1. 命名, 編號(一般會結合功能進行命名)
  2. 目的描述
  3. 測試類型(該測試用例屬於功能測試,性能測試,單元測試,系統測試等等)
  4. 環境
  5. 測試數據
  6. 前提
  7. 步驟
  8. 期望結果
  9. 實際結果
  10. 測試結果(通過還是失敗)

一般來說測試用例,不會說明備份系統,還原系統的步驟,這兩個步驟一般都會由自動化腳本自動執行。

 

8. 簡潔性

Uses active case language。使用主動語氣語句,就是動詞搭配名字的語句,比如Put value, Click button. 不使用, please put value, you go to…

Does not exceed 15 steps。不超過15步。

Matrix does not take longer than 20 minutes to test。執行時間不要超過20分鐘。這兩點其實是希望測試用例的規模比較小,粒度不要太大。這點在大型系統不太適用。

這裏給出了一個測試用例編寫的指導規範。儘量簡潔,精悍。

 

9. 完整性

Automated scrīpt is commented with purpose, inputs, expected results。自動化腳本應該包含必要的註釋,包括,目的,輸入,預期結果。

Setup offers alternative to prerequisite tests, if possible。 如果可能,提供不同的前置條件下的測試。

測試用例應該儘量完整,包含自動化腳本。

 

10. 有效性

Is in correct business scenario order with other tests? 測試用例是否符合商業案例?

 

11. 獨立性

測試用例應該保持獨立性,一個測試用例最好是能獨立運行,不依賴於其他的測試用例的輸出結果。出於結構的考慮,有些特殊測試用例設計本身就是作爲setup來設計的,這個除外。

 

 

二, 測試用例的配置管理

 

Employs naming and numbering conventions。 採用命名和編號規範歸檔。

Saved in specified formats, file types

Is versioned to match software under test? 用例版本是否與當前被測試軟件版本一致(對應)。測試用例最好有版本控制

Includes test objects needed by the case, such as databases? 包含用例需要的相應測試對象,如特定數據庫。

Stored as read 存檔閱讀。

Stored with controlled access 存檔時按角色控制訪問方式

Stored where network backup operates 當網絡備份時存檔。

Archived off-site 離線歸檔。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章