怎样写测试用例?

测试用例是什么?

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

怎样写测试用例?

这篇文章将介绍如何写标准的测试用例,按下面的步骤进行:

创建测试场景(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: lNf9Oti72h

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: lNf9Oti72h

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: lNf9Oti72hLogin 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: lNf9Oti72hLogin 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值