|
如何编写更好的测试用例
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.
分步型。图1显示了此格式外观上的基本要素。包括其他测试要素的此格式的完整视图的模板如附录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.
矩阵或表格。图2显示了此格式外观上的基本要素。包括其他测试要素的此格式的完整视图的模板如附录C所示。
Figure 2 - Detail of matrix test case
Automated script. Figure three shows what this format looks like.
自动化脚本。图3显示了此格式的外观。
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
图形用户界面(Graphical User Interface)
• 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.
分步型用例不一定需要如图1所示的具体到按键说明层次的详细步骤。用例中的行为步骤可以是更高层次的,例如:打开“my account”页面,在某个日期范围内搜索事务,指出范围:______,打印报表,转发报表等等。
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 functions and objects, must be written by programmers. A team can be put together with several people doing the ordinary record/playback scripting and one person doing the programming.
管理部门必须配备人员用诸如C++和Visual Basic等语言进行编程。简单脚本可以由多数测试分析员进行录制,但是许多功能强大的脚本,常常使用自定义函数和对象,则必须由编程人员来编写。一个组里可以由一些人做脚本的录制和回放工作,一个人进行编程。
Comparisons to the other types of test cases apply to record and playback, or data driven scripts. Besides record/playback scripts, automated tools are used for performance and load testing. They may use manual step-by-step cases or matrixes which detail how automated tools will be used to create virtual users, launch transaction scripts, monitor performance, and other activities.
与其他测试用例类型相比较,此用例类型适用于录制和回放脚本,或数据驱动脚本。除了录制/回放脚本,自动化工具还用于性能和负载测试。可以使用手工分步型用例或矩阵来详细说明如何使用自动化工具创建虚拟用户、启动事务脚本、监控性能及其他活动。
(未完,待续)
[ 本帖最后由 caueva2006 于 2010-7-9 18:56 编辑 ] |
|