当前位置:网站首页>怎样写测试用例?
怎样写测试用例?
2022-08-02 03:34:00 【IICOOM】
测试用例是什么?
一个测试用例就是为了验证软件功能,而设计的一系列操作。一个测试用例应该包括测试的步骤,测试数据,前置条件,后置条件,特殊的测试场景。可能还需要站在用户的角度来思考软件是否能够满足用户的使用。
怎样写测试用例?
这篇文章将介绍如何写标准的测试用例,按下面的步骤进行:
创建测试场景(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: [email protected] 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 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: [email protected] 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 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: [email protected] Password: lNf9Oti72h | 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: [email protected] Password: lNf9Oti72h | 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
边栏推荐
猜你喜欢
随机推荐
引擎开发日志:集成Bullet3物理引擎
2019 - ICCV - 图像修复 Image Inpainting 论文导读《StructureFlow: Image Inpainting via Structure-aware ~~》
实现动态库(DLL)之间内存统一管理
开源代码交叉编译操作流程及遇到的问题解决(lightdm)
汇编语言跳转指令总结
剑指Offer 64.求1+2+...+n 递归+&&
使用pyqt弹出消息提示框
【plang 1.4.4】编写贪吃蛇脚本
rosdep update失败解决办法(亲测有效)
Beckhoff ET2000 listener use
剑指Offer 34.二叉树中和为某一值的路径 dfs+回溯
哈希表解题方法
【plang 1.4.6】Plang高级编程语言(发布)
GM7150,振芯科技,视频解码器,CVBS转BT656/601,QFN32,替换TVP5150/CJC5150
本地数据库 sqlite3 编译和使用
STM32 CAN 介绍以及相关配置
剑指Offer 31.栈的压入、弹出
如何搭建私有云盘?
【多线程】线程安全保护机制
引擎开发日志:OpenGL资源多线程加载