摘要
面向对象软件不同于传统的面向过程软件,其具有封装性、继承性和多态性。面向对象软件中类的方法中可能会调用其他类的对象,导致很难获取其他类的对象状态,并且由于其继承性和多态性,程序中可能存在多种执行路径,如果用传统方法生成测试用例,很难达到较高的测试覆盖率。针对这个问题,提出一种新的面向对象软件单元测试用例生成方法。这一方法基于改进的模拟退火遗传算法,使得优化过的测试序列可以覆盖到程序中更多的分支,生成的测试用例具有更高的覆盖率。通过实验验证方法的可行性,并与其他方法进行对比实验。实验结果证明该方法具有较高的分支覆盖率。
Different from procedure-oriented software, object-oriented program has encapsulation, inheritance and polymorphism. The methods of classes in object-oriented program may call the objects of other classes. But it is too difficult to get the real objects state. And because of its inheritance and polymorphism, there may have a variety of program execution path. It is difficult to achieve satisfy the test coverage if it use the conventional method to generate the test cases. Aiming at this problem, proposes an approach of object-oriented program unit test case generation based on improved simulated annealing genetic algorithm. The test sequences optimized by simulated annealing genetic algorithm can cover more branches in the program, the generated test cases will have higher coverage. Finally, the feasibility of the method is verified by the experiments and compared with other methods. Experimental results show that the proposed approach has higher branch coverage.
基金
四川省应用基础研究项目(No.2014JY0112)
关键词
测试用例生成
方法调用序列
模拟退火遗传算法
分支覆盖率
Test Case Generation
Method-Call Sequence
Simulated Annealing Genetic Algorithms
Branch Coverage