为了提高路径覆盖测试数据生成效率,研究了路径自动分割方法并结合人工鱼群算法提出了一种路径覆盖测试数据生成方法.首先在分析变量与节点关系、变量与路径关系的基础上提出了路径分割的自动判定及分离算法,实现了变量对子路径有无影响的自动判定;其次引入Levy飞行策略和共轭梯度法对人工鱼群算法进行了改进;然后结合路径分离的结果和改进的人工鱼群算法实现路径覆盖测试数据的生成.在利用人工鱼生成测试数据的过程中,判断是否有人工鱼穿越分离的子路径.如果有,则记录人工鱼中穿越子路径相应的分量并在人工鱼的觅食、聚群及追尾等行为中固定这些分量,从而使得搜索空间不断减少.最后将提出的方法实现程序的测试数据生成,并与相关方法进行了比较.实验结果表明,本文方法在时间开销、成功率及算法稳定性等方面均具有优越性.
In order to improve the efficiency of test data generation for path coverage,a method for generating test data was proposed,which was based on automatic division of path and artificial fish-swarm( AFS) algorithm. Firstly,the relations between variables and nodes,and between variables and paths,were analyzed. Based on the analysis an algorithm for automatic division of path was presented,which can automatically judge the impact of variables on sub-paths. Secondly,an improved AFS algorithm was developed based on Levy flying and conjugate gradient. By making use of the result of path division and the improved AFS algorithm,a newmethod for searching test data was proposed. If there exist sub paths that the fish pass through in the process of using AFS to generate test data,the corresponding component of these fish were fixed,so that search space were reduced. Finally,the proposed method was applied to the test data generation of programs. It is shown that our method outperforms the related methods in running time,success rate and stability.