正交实验法设计测试用例
上一篇 /
下一篇 2010-05-04 21:59:48
正交实验法设计测试用例是考虑用最少的用例来覆盖两两组合的情况,是套用正交表来随机的产生用例,没有主次之分,是一种提高测试覆盖率的简单易用的方法。 正交实验法的重点是首先确定因子、状态,生成因子状态表;然后用加权筛选的方法去除不重要的因子、状态得到简化的因子状态表(因素分析表);再利用正交表构造测试数据集。
如何选择正交表呢?有几条原则:
1 每个因子状态数目相同的情况,因子数为M,状态数为N,则最佳选择一个M因子N状态的正交表,如果不存在这样的正交表,则选择K因子N状态的正交表(K>M)。
2 如果不同因子状态数目不相同,选择出现次数最多的状态数(相同的话选择大的)。
3 如果所选的正交表的状态数小于因子最大的状态数,比如
a1 a2
b1 b2 b3
c1 c2
则把b1 b2放在一起,写用例的时候再分开写。
a1 | b1b2 | c1 |
a2 | b1b2 | c2 |
a1 | b3 | c2 |
a2 | b3 | c1 |
用例:
a1 b1 c1
a1 b2 c1
a2 b1 c2
a2 b2 c2
a1 b3 c2
a2 b3 c1
正交表的下载网址http://www.york.ac.uk/depts/maths/tables/orthogonal.htm
正交实验法设计测试用例的例子:
假设一个WEB站点,该站点有大量的服务器和操作系统,并且有许多具有各种插件的浏览器浏览:
WEB浏览器:Netscape6.2、IE6.0、Opera4.0
插件: 无、RealPlayer、MediaPlayer
应用服务器:IIS、Apche、Netscape Enterprise
操作系统:Windows2000、WindowsNT、Linux
| WEB浏览器 | 插件 | 应用服务器 | 操作系统 |
1 | Netscape6.2 | 无 | IIS | Windows2000 |
2 | Netscape6.2 | RealPlayer | Apche | Windows NT |
3 | Netscape6.2 | MediaPlayer | Netscape | Linux |
4 | IE6.0 | 无 | Apche | Linux |
5 | IE6.0 | RealPlayer | Netscape | Windows2000 |
6 | IE6.0 | MediaPlayer | IIS | Windows NT |
7 | Opera4.0 | 无 | Netscape | Windows NT |
8 | Opera4.0 | RealPlayer | IIS | Linux |
9 | Opera4.0 | MediaPlayer | Apche | Windows2000 |
正交表:
| 1 | 2 | 3 | 4 |
1 | 1 | 1 | 1 | 1 |
2 | 1 | 2 | 2 | 2 |
3 | 1 | 3 | 3 | 3 |
4 | 2 | 1 | 2 | 3 |
5 | 2 | 2 | 3 | 1 |
6 | 2 | 3 | 1 | 2 |
7 | 3 | 1 | 3 | 2 |
8 | 3 | 2 | 1 | 3 |
9 | 3 | 3 | 2 | 1 |
一、 提取系统功能说明中的因子:
1、WEB浏览器
2、插件
3、应用服务器
4、操作系统
二、 分析各因子的状态
1、WEB浏览器:1=Netscape6.2、2=IE6.0、3=Opera4.0
2、插件: 1=None、2=RealPlayer、3=MediaPlayer
3、应用服务器: 1=IIS、2=Apche、3=Netscape Enterprise
4、操作系统: 1=Windows2000、2=Windows NT、3=Linux
三、 将因子、状态映射到上面正交表中:
测试用例 | 浏览器 | 插件 | 服务器 | 操作系统 |
1 | Netscape6.2 | None | IIS | Windows2000 |
2 | Netscape6.2 | RealPlayer | Apche | Windows NT |
3 | Netscape6.2 | MediaPlayer | Netscape Enterprise | Linux |
4 | IE6.0 | None | Apche | Linux |
5 | IE6.0 | RealPlayer | Netscape Enterprise | Windows2000 |
6 | IE6.0 | MediaPlayer | IIS | Windows NT |
7 | Opera4.0 | None | Netscape Enterprise | Windows NT |
8 | Opera4.0 | RealPlayer | IIS | Linux |
9 | Opera4.0 | MediaPlayer |
|
收藏
举报
TAG: