回归测试是迭代式软件开发的重要环节,测试数据生成是回归测试的前提.传统的回归测试方法,从已有的测试数据中选择部分测试数据,并生成一些新的测试数据,以验证程序的正确性.但是,该方法容易生成冗余的测试数据,从而降低了回归测试的效率.研究了回归测试的分支覆盖问题,通过利用已有测试数据的路径覆盖信息,并选择一定个数的路径,以覆盖所有的目标分支.首先,以若干路径形成的集合作为决策变量,以路径最少、覆盖的分支最多以及包含的未覆盖路径最少为目标,建立路径选择问题的3目标优化模型;然后,采用遗传算法求解上述模型时,设计了基于目标重要性的个体评价策略;最后,基于已有的测试数据与选择的路径之间的覆盖关系,确定需要生成的测试数据.将所提方法应用于6个基准工业程序测试中,并与其他方法比较.实验结果表明,采用该方法选择的路径,能够覆盖更多的分支,需要生成的测试数据更少,回归测试消耗的时间更短.
Regression testing is an important part of the iterative software development, and test data generation is the premise of regression testing. Traditional regression testing methods select a part of test data from existing ones, and generate a number of new test data, so as to verify the correctness of a program. However, these methods are prone to generate redundant test data, therefore reducing the efficiency of regression testing. This paper researches the problem of branch coverage for regression testing, makes full use of information on the path coverage from existing test data, and selects a certain number of paths to cover all the target branches. First, taking a set consisting of several paths as the decision variable, the least number of paths, the largest number of covered branches, and the least number of uncovered paths as the objectives, a 3-objective optimization model for the problem of selecting paths is established. Then, a strategy of evaluating an individual based on the importance of an objective is designed in solving the above model using genetic algorithm. Finally, test data required to generate is determined according to the relation between existing test data and the selected paths. The proposed method is applied to test six benchmark and industrial programs, and compared with other regression testing methods. The experimental results show that paths selected by the proposed method can cover more branches, with fewer test data required to generate and less time consumption for regression testing.