没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
How to Write Better Test Cases
by Dianne L. Runnels, CQA, CSTE
Interim Technology Consulting
Investing in test cases
What is it worth to improve test cases? What risk would impel you to invest in better test cases? As long
as they cover the software requirements, isn't that good enough? The answer to these questions is that
poor test cases do indeed expose you to considerable risk. They may cover the requirements in theory,
but are hard to test and have ambiguous results. Better tests have more reliable results as well as
lowering costs in three categories:
1. Productivity - less time to write and maintain cases
2. Testability - less time to execute them
3. Scheduling reliability- better reliability in estimates
This paper describes how to avoid the losses that are inevitable with poor test cases. It will look under the
hood of different kinds of test cases and show where and how to build in the quality that controls risk. It
will give practical advice on how to improve productivity, usability, scheduling reliability, and asset
management. Once you understand the whats and whys of test cases, you can use a checklist of
standards, like the one attached as Appendix A, to identify areas of risk and improve your current and
future test cases.
The most extensive effort in preparing to test software is writing test cases. The incentive to build robust
test cases is spurred by the likelihood they will be reused for maintenance releases. Over half of all
software development is maintenance projects. How can you write quality test cases that will deliver
economical testing the first time plus live again as regression tests? Let's get started with the answer by
lifting the hood of a test case and looking at what's inside.
Looking inside test cases
Elements of test cases
For our purposes, a test case is a set of actions with expected results based on requirements for the
system. The case includes these elements:
• The purpose of the test or description of what requirement is being tested
• The method of how it will be tested
• The setup to test: version of application under test, hardware, software, operating system, data files,
security access, time of day, logical or physical date, prerequisites such as other tests, and any
another other setup information pertinent to the requirement(s) being tested
• Actions and expected results, or inputs and outputs
• Any proofs or attachments (optional)
These same elements need to be in test cases for every level of testing -- unit, integration, system, or
acceptance testing. They are valid for functional, performance, and usability testing. The "expected
results" standard does not apply to diagnostic or other testing of an exploratory nature. Even diagnostic
testing needs the other elements in its cases. However, if the test measures performance that should fall
in a range, this is an expected result.
An alternate description of test cases is that the description, purpose, and setup is the case or
specification. The steps to accomplish it are called a script. Yet another view calls the purpose or
description a scenario or use case. These views are all compatible with the quality assessments and
improvements suggested in this paper.
Quality of test cases
There is a misconception that quality of writing is subjective, like looking at a painting, where beauty is in
the eye of the beholder. In fact, quality of writing is objective and measurable. It is simple to set up an
objective checklist, like the one in Appendix A, of the structural elements of test cases -- purpose,
Dianne L. Runnels How to write better test cases Page 2 of 12
method, setup, inputs and outputs. Then walk though each case. Is the element there or not? In addition
to their structure, the cases must also meet these standards of quality:
Accurate. They test what their descriptions say they will test.
Economical. They have only the steps or fields needed for their purpose. They don't give a guided tour of
the software.
Repeatable, self standing. A test case is a controlled experiment. It should get the same results every
time no matter who tests it. If only the writer can test it and get the result, or If the test gets different
results for different testers, it needs more work in the setup or actions.
Appropriate. A test case has to be appropriate for the testers and environment. If it is theoretically sound
but requires skills that none of the testers have, it will sit on the shelf. Even if you know who is testing the
first time, you need to consider down the road -- maintenance and regression.
Traceable. You have to know what requirement the case is testing. It may meet all the other standards,
but if its result, pass or fail, doesn't matter, why bother?
Self cleaning. Picks up after itself. It returns the test environment to the pre-test state. For example, it
doesn't leave the test system set at the wrong date. Automated scripts may call other scripts to do this.
Don't confuse this standard with being destructive. Tests should be destructive, including trying to break a
simulated production environment in controlled, repeatable ways.
These standards are also objective and measurable. They could also be added to your checklist.
Someone who knows the requirements and application under test could fill out the checklist as part of a
peer review. Compliance with some of the standards can't be known until after testing, but they are all
measurable. This is an especially helpful exercise for new test writers to see where they consistently miss
one of the elements, or don't meet a standard.
Format of test cases
What does a test case look like? They seem to fall into three major groups: step-by-step, matrix, and
automated script. While the automated script will run as an online document, there is no assumption that
the other two must be paper-based. They, too, might be online. Let's look at each of the formats:
Step-by-step. Figure one shows what the basics of this format looks like. A complete view of this format,
in a template with other test elements is displayed as Appendix B.
Step Action Expected Result
1 Enter new name and address. Press <OK>. Displays screen 008 new name details.
2 Fill all blanks with natural data. Make screen
grab. Press <OK>.
Displays screen 005 maintenance.
3 Click on <Inquiry> button. Displays screen 009 inquiry details.
4 Enter name from screen grab. Press <OK>. Displays screen 010 record detail.
5 Compare record detail with screen grab. All details match exactly.
Figure 1 - Detail of step-by-step test case
Matrix or table. Figure two shows what the basics of this format looks like. A complete view of the format,
in a template with other test elements is displayed as Appendix C.
Date Hired
After 1/96
401K Life
Insurance
Payment
Computation
10/25/99 Y 1 3 $24.50
1/4/98 Y 3 1 $34.00
3/6/96 N 2 5 $48.00
8/15/96 Y 2 5 $86.25
8/15/96 N 2 5 $105.00
Figure 2 - Detail of matrix test case
Dianne L. Runnels How to write better test cases Page 3 of 12
Automated script. Figure three shows what this format looks like.
Figure 3 - Detail of automated script test case
Using test types
Best uses for each type of case
The most productive uses for step-by-step cases are:
Step-by-step
• One-off test cases, each one different
• Business scenario goes from screen to screen
• Many processing rules
• GUI interfaces
• Input and output hard to represent in a matrix
Step-by-step cases do not necessarily need to have a key press level of detail as shown in Figure 1. The
action steps can be at a higher level, such as: open "my account" page, search for transactions in a date
range, note the range: ______ , print report, forward report, and so forth.
Matrix. The most productive uses for matrix cases are:
• Many variations of filling out a form, same fields, different values, input files
• Same inputs, different platforms, browsers, configurations
• Character based screens
• Input and outputs best represented in a matrix
Nearly any test can be represented in a matrix, but the question to decide is whether a matrix is the best
way to test. It is most important that the matrix be supported by a description, setup, and how to record
results for the test. It may be obvious to the writer how to test the matrix, but without more guidance the
tester could flounder.
A variation of the matrix is a list of inputs. It can be inserted in a step-by-step test or stand as a matrix with
the explanatory elements of the test.
Automated scripts. A decision to use automated testing software is more related to the project and
organization doing the testing than to what is being tested. There are some technical issues that must be
met, varying from tool to tool, but most applications can find a technical fit. The project management must
understand that writing automated cases takes longer than manual tests because the manual tests must
be still be written first. When the interface is stable, then the tests can be recorded. The real payback of
automated testing comes in the maintenance phase of the software lifecycle. Then the scripts can be
executed repeatedly, even unattended, for great savings in testing time.
The management must provide someone to program in the tool language, such as C++ or Visual Basic.
Simple scripts can be recorded by most test analysts, but more powerful scripts, often utilizing custom
# Open the Fax Form
menu_select_item ("File;Fax Order...");
set_window("Fax Order");
# Retrieve the Fax Order information and compare it to data from the main window
edit_get_text("Arrival:", text);
if(main_data["arr_time"] != text)
{
failure_msg = arrival_fr_mismatch;
result = FAIL;
剩余11页未读,继续阅读
资源评论
aotup
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功