| 摘要: |
| 结合机器学习相关技术的启发式测试用例生成方法可显著提高测试效率. 已有研究关注于利用部分测试用例构建高效的代理模型, 忽略了初始种群质量以及代理模型对多路径测试效率的影响. 由此, 提出一种结合K-means与SVR (support vector machine regression, 支持向量机回归)的测试用例约简与生成方法. 通过K-means将随机生成的用例聚为若干簇, 保留与簇中心距离在一定阈值内的用例, 生成这些用例的路径覆盖矩阵. 利用该矩阵评估测试用例的路径覆盖潜能以及路径的难易覆盖程度, 并基于这两者对测试用例进行排序, 分别从不同簇中选取若干用例构成测试用例约简集, 将其作为初始遗传种群. 这不仅增强初始种群的多样性, 降低其冗余性, 还有助于减少多路径覆盖的测试用例进化次数. 同时, 将聚类前的用例及其适应度作为样本训练适应于多路径覆盖的SVR适应度预测模型, 并使用遗传进化生成的新用例更新模型, 进一步提高模型精度, 可减少执行插桩程序带来的大量时间消耗. 这样, 种群质量与测试效率均得以提升. 实验表明, 在15个程序上, 所提方法在覆盖率、平均进化代数等指标上均有较好改善. 其中在覆盖率上, 与3类基准方法相比, 最少可提高7%, 最多可达49%; 与5种具有竞争性的方法相比, 可提高约10%, 最多可达25%. 所提方法对融合机器学习的多路径测试研究提供了方法指导. |
| 关键词: 测试用例 K-means聚类 支持向量机回归模型 多路径覆盖 遗传算法 |
| DOI:10.13328/j.cnki.jos.007472 |
| 分类号:TP311 |
| 基金项目:国家自然科学基金(62262025); 赣鄱俊才支持计划主要学科学术和技术带头人培养项目 (20243BCE51024); 江西省自然科学基金重点项目(20224ACB202012) |
|
| Test Case Reduction and Generation of Multi-path Coverage Based on K-means and SVR |
|
QIAN Zhong-Sheng, YU Qing-Yuan, FAN Fu-Yu, XU Ke-Wen, CHEN Chao
|
|
School of Computing and Artificial Intelligence, Jiangxi University of Finance and Economics, Nanchang 330013, China
|
| Abstract: |
| The heuristic test case generation method that combines machine learning-related technologies can significantly improve the test efficiency. Existing studies focus on building efficient surrogate models with partial test cases, but ignore the influence of both the initial population quality and surrogate models on the multi-path testing efficiency. Therefore, this study proposes a test case reduction and generation method combining K-means and support vector machine regression (SVR). The randomly generated test cases are clustered into several clusters by adopting K-means, and only the test cases that are within a particular distance away from the cluster center are retained, with the path coverage matrix for these test cases constructed. This matrix is employed to evaluate the path coverage potential of test cases and the coverage difficulty of paths. Additionally, based on these two conditions, the test cases are ranked, and several test cases are selected from different clusters to construct the test case reduction set, which is taken as the initial genetic population. This not only increases the diversity of the initial population and reduces its redundancy, but also helps to reduce the iteration number for multi-path coverage test cases. Meanwhile, the test cases before clustering and their fitness are employed as the samples to train the SVR fitness prediction model designed for multi-path coverage, and then the new test cases generated by genetic evolution are utilized to update the model, thus improving the model accuracy and reducing the time consumed due to the instrumentation program execution. In this way, both population quality and test efficiency can be improved. The experimental results show that on fifteen programs, the proposed method has better improvements in terms of indicators such as the coverage rate and average evolutionary generation. Specifically, in terms of the coverage rate, the proposed method demonstrates an improvement of at least 7% and up to 49% compared to three types of baseline methods, and shows the enhancement of approximately 10% to a maximum of 25% compared to five competitive methods. The proposed method provides guidance for the research on multi-path testing that combines machine learning. |
| Key words: test case K-means clustering support vector machine regression (SVR) model multi-path coverage genetic algorithm |