測試用例是什麼?
一個測試用例就是為了驗證軟體功能,而設計的一系列操作。一個測試用例應該包括測試的步驟,測試資料,前置條件,後置條件,特殊的測試場景。可能還需要站在使用者的角度來思考軟體是否能夠滿足使用者的使用。
怎樣寫測試用例?
這篇文章將介紹如何寫標準的測試用例,按下面的步驟進行:
建立測試場景(Test Scenario)
Let’s create a Test Case for the scenario: Check Login Functionality
為使用者登入的場景建立測試用例:
Step 1) A simple test case to explain the scenario would be(一個測試用例描述的測試場景)
Test Case | Test Case Description |
---|---|
1 | Check response when valid email and password is entered |
Step 2) Test the Data.
In order to execute the test case, you would need Test Data. Adding it below(準備測試資料)
Test Case | Test Case Description | Test Data |
---|---|---|
1 | Check response when valid email and password is entered | Email: guru99@email.com Password: lNf9^Oti7^2h |
Step 3) Perform actions.
In order to execute a test case, a tester needs to perform a specific set of actions on the AUT. This is documented as below:(測試步驟)
Test Case | Test Case Description | Test Steps | Test Data |
---|---|---|---|
1 | Check response when valid email and password is entered | 1) Enter Email Address 2) Enter Password 3) Click Sign in | Email: guru99@email.com Password: lNf9^Oti7^2h |
Step 4) Check behavior of the AUT.
The goal of test cases in software testing is to check behavior of the AUT for an expected result. This needs to be documented as below(期望結果)
Test Case | Test Case Description | Test Steps | Test Data | Expected Result |
---|---|---|---|---|
1 | Check response when valid email and password is entered | 1) Enter Email Address 2) Enter Password 3) Click Sign in | Email: guru99@email.com Password: lNf9^Oti7^2h | Login should be successful |
During test execution time, the tester will check expected results against actual results and assign a pass or fail status
在執行期間,測試人員將要檢查期望結果是否與真是結果相同,來決定測試用例是否通過。
Test Case | Test Case Description | Test Steps | Test Data | Expected Result | Actual Result | Pass/Fail |
---|---|---|---|---|---|---|
1 | Check response when valid email and password is entered | 1) Enter Email Address 2) Enter Password 3) Click Sign in | Email: guru99@email.com Password: lNf9^Oti7^2h | Login should be successful | Login was successful | Pass |
Step 5) 執行條件
測試用例執行的前置條件(如:需要安裝xxx,才能進行測試),後置條件(如:測試用例執行結束需要在多長時間內,xxx資料應該已經被儲存到資料庫中)
高質量測試用例具備的條件
Best Practice for writing good Test Case Example.
- 簡單且透明
- 使用使用者思維建立測試用例
- 避免重複
- 不要主觀臆想
- 100%的覆蓋率
- 測試用例ID唯一
- 善於使用測試技巧: Boundary Value Analysis (BVA)邊緣分析、Equivalence Partition (EP) 等類劃分、State Transition Technique 狀態過渡、Error Guessing Technique 錯誤預測 這個比較依賴於測試者的經驗
- Peer Review 同事評估
工具推薦
測試管理工具可以幫助測試者管理維護測試用例。有下面一些特性:
- 藉助工具便捷的建立測試模板
- 方便的執行用例記錄測試結果
- 測試不通過的用例自動提交給開發者追蹤bug
- 可追蹤,更方便的統計測試覆蓋率
Popular Test Management tools are: Quality Center and JIRA
流行的測試管理工具有 uality Center and JIRA
參考
How to Write Test Cases: Sample Template with Examples
Sample Test Case Template With Test Case Examples