类测试中遗传算法与方法依赖图的应用研究

上传人:E**** 文档编号:108177275 上传时间:2019-10-22 格式:PDF 页数:74 大小:4.20MB
返回 下载 相关 举报
类测试中遗传算法与方法依赖图的应用研究_第1页
第1页 / 共74页
类测试中遗传算法与方法依赖图的应用研究_第2页
第2页 / 共74页
类测试中遗传算法与方法依赖图的应用研究_第3页
第3页 / 共74页
类测试中遗传算法与方法依赖图的应用研究_第4页
第4页 / 共74页
类测试中遗传算法与方法依赖图的应用研究_第5页
第5页 / 共74页
点击查看更多>>
资源描述

《类测试中遗传算法与方法依赖图的应用研究》由会员分享,可在线阅读,更多相关《类测试中遗传算法与方法依赖图的应用研究(74页珍藏版)》请在金锄头文库上搜索。

1、南京航空航天大学 硕士学位论文 类测试中遗传算法与方法依赖图的应用研究 姓名:周瑞杰 申请学位级别:硕士 专业:计算机科学与技术 指导教师:江国华 2011-03 南京航空航天大学硕士学位论文 I 摘 要 随着面向对象软件开发技术的快速发展,面向对象程序设计的软件测试逐渐成 为当前测试研究的主要内容。本文对传统的软件测试方法和遗传算法在测试中的应 用做了详细的分析研究,在此基础上,深入探讨了方法依赖图和遗传算法在类测试 中的应用。 类不同于基本数据类型,遗传算法中传统的编码方式已不再适用于对类进行编 码。本文给出了一种用于保证类方法之间调用合理性的编码规则,该规则在表示为 种群个体时采用方法调

2、用树形式,它能够对方法之间调用的合理性进行判定。 类具有多继承性、多态性、封装性等特点,本文针对类所特有的性质进行深入 探讨研究,主要包括以下几个方面。 ? 现有的方法依赖图并不能够对类的多继承性特点进行表达,本文对方法依 赖图进行了扩展,使得能够表示具有继承关系的类之间的联系,并给出了 指导此种表示方法时的测试用例生成准则。 ? 类的实例具有多个不同状态,为了达到对实例所有状态的测试覆盖,使用 了基于状态迁移图表示的对象状态模型进行测试,并给出了构造对象状态 模型的方法步骤。 ? 方法接收的参数为对象类,且子类实例也可以作为参数传递给方法,在方 法依赖图需要对此种情况进行表示,本文给出了这种

3、情况的测试用例生成 准则,用于指导测试用例生成。 ? 在利用遗传算法生成测试用例时采用了扩展的海明距离法作为评估方法, 为了防止种群过早的陷入局部最优解,引入了“缩放法”对评估值进行处 理,使得“早熟”问题得到了很好的解决。 本文的最后一部分实现了一个针对 C+语言所书写的类的测试用例自动生成 原型工具,并把所产生的测试序列转换为 C+代码片段,再利用单元测试框架 CppUnit 执行,以验证用例执行结果与预期结果的一致性,实验证明该方法是有效 可行的。 关键词:关键词:面向对象,软件测试,遗传算法,测试用例,类测试,方法依赖图 基于遗传算法的面向对象类测试用例生成研究 II Abstract

4、 With the rapid development of the object-oriented software development technology, object-oriented programming software testing has become the main topic of the current software testing. In this paper, the traditional software testing methods and genetic algorithm application in the software testin

5、g made a detailed analysis.the application of method dependence graph and genetic algorithms in class testing are mainly talked about. Class is different from the basic types, the traditional genetic algorithm encoding is no longer applicable to the class code.In this paper, give a encoding rules,wh

6、ich is used to ensure method call reasonable between classes.population individual is in form of method call tree expressing the rules which can make a rational decision among the methods calls. Class has own features includes polymoriphism, encapsulation and inheritance,it mainly focused the featur

7、es and give a detail investigation,such as follows. ? The traditional method dependence graph is not able to express the characteristics of inheritance.extended method dependence graph in order to express the characteristics between the links of class.and gives the test case generation criteria to g

8、uide test case generation. ? Instances of class with lots of different states,in order to achieve test coverage for all instances states,the use of object state modeling based on the state transition graph testing,and give the detailed steps about constructing object state model. ? Some methods of c

9、lass can receive class objects as parameters, and the child class object can be passed as an argument,in the paper gives guidelines for test case generation for this situation to guide test case generation. ? In genetic algorithm used the extended Hamming distance as evaluation method,in order to pr

10、event the premature population into local-optimal solution, the introduction of the “scaling-zooming methods” to deal with the value of fitness,it can be resolved the “premature“ problem very well. The last part of this article implements a tool prototype for automatic generation of test case class

11、with C+ language written, and the resulting test sequence are converted to C+ code fragment,and used unit testing framework CppUnit to excute the use cases,compare the actual results and expected result consistently. Expriment result proved that the method is feasible and effective. Keywords: Object

12、-Oriented, Software Testing, Genetic Algorithm , Test Case, Class testing, Method Dependence Graph 南京航空航天大学硕士学位论文 V 图表清单 图 2.1 传统测试与类测试区别.9 图 2.2 类基本结构9 图 3.1 基本遗传算法流程图.14 图 4.1 类 Sequence 与类 bTree 的方法依赖图.18 图 4.2 seqtotree 的方法调用树.19 图 4.3 改进后 seqtotree 方法调用树.20 图 4.4 子树交叉示例21 图 4.5 子树变异示例22 图 4.6 输

13、入值变异实例.22 图 4.7 构造方法变异实例23 图 4.8 子树移除 23 图 4.9 结点子树插入24 图 4.10 类之间的继承关系25 图 4.11 包含继承的方法依赖图.26 图 4.12 equals 方法依赖树.27 图 4.13 简化的 equals 方法依赖树28 图 4.14 状态迁移图示例30 图 4.15 类 Stack 的状态迁移模型.31 图 4.16 类 IntegerRange 状态迁移.32 图 4.17 测试序列转换成 C+源码.34 图 4.18 调用依赖图的路径覆盖34 图 5.1 系统基本流程图.43 图 5.2 读入数据的存储结构44 图 5.3

14、 基本数据构造界面.45 图 5.4 遗传测试用例生成界面.46 图 5.5 seqtotree 方法依赖树.49 图 5.6 简化的 seqtotree 方法依赖树49 图 5.7 seqtotree 方法依赖树.50 图 5.8 相对应的 C+代码片段.50 图 5.9 待测试单元选择截图52 图 5.10 测试失败情况.53 图 5.11 测试成功情况.53 表 4. 1 类 Stack 分析之后结果.31 表 5. 1 类型集的表示.47 表 5. 2 方法集 .48 基于遗传算法的面向对象类测试用例生成研究 VI 注释表 缩写 英文全称 注释 GA Genetic Algorithm

15、 遗传算法 GUI Graph User Interface 图形用户接口 UML Unified Modeling Language 同一建模语言 承诺书 本人声明所呈交的学位论文是本人在导师指导下进行的 研究工作及取得的研究成果。除了文中特别加以标注和致谢的 地方外,论文中不包含其他人已经发表或撰写过的研究成果, 也不包含为获得南京航空航天大学或其他教育机构的学位或 证书而使用过的材料。 本人授权南京航空航天大学可以将学位论文的全部或部 分内容编入有关数据库进行检索,可以采用影印、缩印或扫描 等复制手段保存、汇编学位论文。 (保密的学位论文在解密后适用本承诺书) 作者签名: 日 期: 南京

16、航空航天大学硕士学位论文 1 第一章 绪论 1.1 研究背景和意义 随着软件规模的增长,人们对软件的质量的重视程度越来越高,软件质量的好坏直接影响 了用户使用的满意度和软件未来的发展。软件测试作为软件质量保证重要手段,在这个方面发 挥着不可替代的作用。 软件测试是包含在软件工程实施过程中的一部分,是一系列以事先计划并且可以进行系统 管理的活动,软件测试活动应当从软件产品项目立项就开始进行规划,并且随着软件开发活动 的进行而逐步的完善进行。有资料统计显示表明,软件测试和错误排查所花费的代价约为软件 开发总代价的 40%左右1。但即使如此也不能保证软件中不再隐藏缺陷。作为软件质量保证手 段的测试技术,在现在的软件产品开发中越来越引起开发人员和用户的关注。 近些年来, 传统的软件测试技术得到了很好的发展, 逐步形成了一套比较完整的理论体系、 测试方法也趋于完善。而

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号