您的位置:首页 > 其它

具有约束关系的因素如何实施组合测试

2015-01-20 09:25 387 查看
关键词:组合测试,因素具有约束关系,PICT实施组合测试
PICT的全称是Pairwise Independent Combinatorial Testing tool

本文总结了我在组合测试实践中获得的一些经验,组合测试百度一下有各种博文介绍,不过其中的例子大多是比较简单易懂的,我这里遇到的问题稍稍复杂了一些,因素之间具有约束关系,这里使用微软的工具PICT详细介绍如何定义约束关系生成有效的测试用例集。
假设场景如下:
Cleaning
Y
N
Enable Analyze
Y
N
Normal Processing
Y
N
Terminate on Error
Terminate
Keep Running
Perform Validation
Y
N
Perform Remove
Y
N
Format
Y
N
Type
Upper
Lower
Mixed
最上面一级的两个选项Cleaning, Format
当Cleaning选项开的时候,它的子选项Enable Analyze, Normal Processing, Perform Validation, Perform Remove才可以开
当Normal Processing选项为开的时候,它的子选项Terminate on Error才可以开
当Format选项开的时候,它的子选项Type才可以开

接下来,我们需要新建一个模型文件,文本文件即可



第一部分把选项及其可以取到的值列出来,以逗号分割
第二部分把约束关系列了出来

如果Cleaning选项关闭,则Enable Analyze, Normal Processing, Perform Validation, Perform Remove不能为开
如果Normal Processing选项为开,则Terminate on Error的值只能是Terminate 或者Keep Running
如果Normal Processing 选项为关,则Terminate on Error 的值只能为关
如果Format 选项开,则Type的值是Upper或Lower 或Mixed
如果Format 选项关,则Type 的值只能为关

注意:Terminate on Error 以及Type 这两个选项 事实上是没有N这个值的,我在文件中加入这两个值是为了生成的结果更准确。如果我不加入N, 并且定义约束规则为IF [Format] = "N" THEN [Type] = ""; 则PICT程序会报
Constraints Warning: Restrictive constraints. Output will not contain following values: Format: N
结果不包含Format=N的记录,读者有兴趣可以自行实验。

当PICT读取模型文件时,它会解析约束规则,并将其应用于测试用例生成过程。生成的测试用例集既满足对有效取值组合的覆盖,又不包含无效取值组合。

Pict.exe及模型文件均放在D盘根目录下,在DOS窗口下运行 pict.exe model_file.txt > testing.xls
这里没有使用参数"/o:N", 默认维度是2



打开输出文件 testing.xls 生成了14个测试用例,这些用例中不包含那些无效的取值组合。



到这里为止,工作其实还没有结束,我们还需要根据实际业务场景进一步审查及筛选,还有一些特殊场景不能漏掉,比如全默认选项。全开,全关上述用例已包含。

关于维度以及PICT的其它功能, 参考PICT 3.3
User’s Guide

Pairwise and Higher-Order Generation
By default, PICT generates a pairwise, or order two, suite of test cases–all pairs covered. You can set the order to a value larger than two using the option /o:. For example, if you specify /o:3, the
resultant test cases will cover all triplets of values, producing a larger number of tests than the pairwise option, but potentially giving the test suite more coverage. The maximum order for a simple model is equal to the number of parameters, which will
result in an exhaustive, all possible combinations, test suite. Following the same principle, specifying /o:1 will produce a test suite that covers all values only once (combinations of 1).

《微软的软件测试之道》建议从两因素组合测试开始,逐渐提高组合维度,直至6因素组合测试,因为有研究表明6因素组合测试可以发现绝大多数的程序缺陷。但是,随着组合维度的提高,测试用例数呈爆炸式增长。

PICT下载地址:http://download.microsoft.com/download/f/5/5/f55484df-8494-48fa-8dbd-8c6f76cc014b/pict33.msi

关于组合测试还有其它工具可以参照,例如
James Bach使用Perl语言开发了一个allpairs工具用于全对偶测试,本工具的下载地址:http://www.satisfice.com/tools/pairs.zip

美国Telcordia 技术公司有一个基于web的工具,它产生的结果集要优于全对偶测试(All Pairs)得到的结果集。
例如,存在40个参数且都有3个值的情况,这个工具可以使用21个测试用例来覆盖所有的pairs。全对偶测试(All Pairs) 则需要29个测试用例才能达到同样的效果,但是这个工具是收费的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: