变异分析能够辅助生成有效的测试用例集,然而,高昂的测试代价,严重影响了这一技术在实际软件测试中的广泛应用.文中基于弱变异分析,研究求解测试用例生成问题的新方法,以高效地生成具有很高缺陷检测能力的测试用例集.该方法首先利用变异前后的语句,构造变异分支,并将所有变异分支集成到原程序,形成新的被测程序;然后,以测试用例集作为决策变量,根据该测试用例集对变异分支的覆盖信息,构造目标函数,建立新的测试用例生成问题的数学模型;最后,采用集合进化优化方法求解上述模型时,设计具有针对性的适应度函数和进化策略,使得一次求解该模型,生成杀死所有变异体的测试用例.将所提方法应用于13个基准和工业程序的测试,并与传统的遗传算法进行了比较.实验结果表明,所提方法能够高效地生成测试用例,且生成的测试用例具有更高的缺陷检测能力.
Mutation analysis can assist in generating effective test cases.However,the high cost in mutation testing has affected its widespread application in practical software testing.Based on the weak mutation analysis,we proposed a new method to effectively generate test cases with a high ability in detecting defects.In our method,mutant branches are constructed from statements before and after mutation,and a new program is formed by integrating all mutant branches into the original program.Then,a novel model is established for optimizing test case generation.In the model,the decision variable is a test suite,and the objective is defined based on the coverage information of the test suite to all mutant branches.Finally,when solving the above model by using the set-based evolutionary optimization method,an appropriate fitness function and genetic operators are designed,so as to generate test cases that kill all mutants by running the method once.The proposed method was applied to thirteen benchmark and industrial programs,and compared with the traditional genetic algorithm.Our experimental results showed that our method can effectively generate test cases,and the generated test cases have a higher ability in detecting defects.