关于测试:怎样写测试用例

34次阅读

共计 2256 个字符,预计需要花费 6 分钟才能阅读完成。

测试用例是什么?

一个测试用例就是为了验证软件性能,而设计的一系列操作。一个测试用例应该包含测试的步骤,测试数据,前置条件,后置条件,非凡的测试场景。可能还须要站在用户的角度来思考软件是否可能满足用户的应用。

怎么写测试用例?

这篇文章将介绍如何写规范的测试用例,按上面的步骤进行:

创立测试场景(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 CaseTest Case Description
1Check 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 CaseTest Case DescriptionTest Data
1Check response when valid email and password is enteredEmail: 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 CaseTest Case DescriptionTest StepsTest Data
1Check response when valid email and password is entered1) Enter Email Address 2) Enter Password 3) Click Sign inEmail: 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 CaseTest Case DescriptionTest StepsTest DataExpected Result
1Check response when valid email and password is entered1) Enter Email Address 2) Enter Password 3) Click Sign inEmail: guru99@email.com Password: lNf9^Oti7^2hLogin should be successful

During test execution time, the tester will check expected results against actual results and assign a pass or fail status
在执行期间,测试人员将要查看冀望后果是否与真是后果雷同,来决定测试用例是否通过。

Test CaseTest Case DescriptionTest StepsTest DataExpected ResultActual ResultPass/Fail
1Check response when valid email and password is entered1) Enter Email Address 2) Enter Password 3) Click Sign inEmail: guru99@email.com Password: lNf9^Oti7^2hLogin should be successfulLogin was successfulPass

Step 5) 运行条件
测试用例运行的前置条件(如:须要装置 xxx,能力进行测试),后置条件(如:测试用例运行完结须要在多长时间内,xxx 数据应该曾经被存储到数据库中)

高质量测试用例具备的条件

Best Practice for writing good Test Case Example.

  1. 简略且通明
  2. 应用用户思维创立测试用例
  3. 防止反复
  4. 不要主观臆想
  5. 100% 的覆盖率
  6. 测试用例 ID 惟一
  7. 长于应用测试技巧:Boundary Value Analysis (BVA)边缘剖析、Equivalence Partition (EP) 等类划分、State Transition Technique 状态过渡、Error Guessing Technique 谬误预测 这个比拟依赖于测试者的教训
  8. Peer Review 共事评估

工具举荐

测试管理工具能够帮忙测试者治理保护测试用例。有上面一些个性:

  1. 借助工具便捷的创立测试模板
  2. 不便的执行用例记录测试后果
  3. 测试不通过的用例主动提交给开发者追踪 bug
  4. 可追踪,更不便的统计测试覆盖率

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

正文完
 0