APP下载

基于遗传算法的UML活动图测试用例优化研究

2015-10-22李浩陈锋

现代电子技术 2015年19期

李浩 陈锋

摘 要: 测试用例的选择在软件测试中十分重要,良好的测试用例可以减少时间和资源的使用,因此提出了一种基于遗传算法的UML活动图自动生成测试用例的算法。通过建立UML活动图模型,将活动图转换为有向图,然后采用深度优先搜索方法获得测试路径,应用遗传算法优化得到测试路径。该算法可以提供优先需要测试的路径,用于自动生成高质量的测试用例,提高测试任务的工作效率。

关键词: UML; 测试用例; 活动图; 深度优先搜索算法; 遗传算法

中图分类号: TN911?34 文献标识码: A 文章编号: 1004?373X(2015)19?0117?04

Abstract: The selection of test cases in software testing is important, and the better test cases can reduce time and resource usage. An algorithm of automatic generation test cases of UML activity diagram based on genetic algorithm is proposed. The activity diagram is converted into digraph by establishing UML activity diagram model. The testing path is acquired by adopting depth first search (DFS) method, and obtained by using genetic algorithm optimization. This algorithm can provide the path needed to be tested first to generate high quality test cases automatically. The work efficiency of the test task can be improved.

Keywords: UML; test case; activity diagram; depth first search method; genetic algorithm

0 引 言

随着信息技术的发展,软件技术在各行业领域中的应用日益广泛。作为软件质量的保证,软件测试在软件开发中的作用逐渐得到重视。国内外相关学者在基于模型的测试技术以及测试用例自动生成上,开展了大量的研究[1?3]。UML(Unified Modeling Language)作为软件建模的标准,激发了研究者极大的热情,UML模型在设计测试用例方面的重要性得到了充分的验证。UML中包含状态图、活动图和序列图等,文献[4?6]给出了基于UML状态图、序列图和协作图生成测试用例的方法。对于描述系统动态行为,UML活动图(Activity Diagram)被认为是最适合描述软件过程的模型[7]。本质上,活动图是一种流程图,该模型是描述系统业务过程的重要工具,不仅能定义活动中对象的角色、属性和状态的变化,也适用于描述满足用例要求所进行的活动以及活动时间的约束关系,强调对象间的控制流程。Rudram研究了如何使用UML活动图生成测试用例的方法[8],提出了形式化的活动图。……

登录APP查看全文