arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2208.09623cs.SEcs.LG
收藏

学习预测测试有效性

Learning to predict test effectiveness

Iran University of Science and Technology(伊朗科技大学)

Morteza Zakeri-Nasrabadi, Saeed Parsa

摘要:

测试的高成本可以显著降低,前提是测试代码的固有特性可覆盖性是可预测的。本文提供了一个机器学习模型,用于根据名为Coverageability的新指标来预测测试可以覆盖某个类别的程度。预测模型由四个回归模型的集合组成。学习样本由特征向量组成,其中特征是为类计算的源代码度量。样本由为其相应类计算的Coverageability值标记。我们提供了一个数学模型来评估测试有效性的大小和覆盖率的测试套件自动生成的每个类。我们通过引入一种新的方法来定义现有的源代码度量的子度量扩展的功能空间的大小。使用学习的预测模型的特征重要性分析,我们排序的源代码度量的顺序,它们对测试有效性的影响。因此,我们发现类严格圈复杂度是最有影响力的源代码度量。我们在包含约23,000个类的大型Java项目语料库上对预测模型进行的实验表明,平均绝对误差(MAE)为0.032,均方误差(MSE)为0.004,R2得分为0.855。与最先进的覆盖率预测模型相比,我们的模型将MAE,MSE和R2得分分别提高了5.78%,2.84%和20.71%。

英文摘要:

The high cost of the test can be dramatically reduced, provided that the coverability as an inherent feature of the code under test is predictable. This article offers a machine learning model to predict the extent to which the test could cover a class in terms of a new metric called Coverageability. The prediction model consists of an ensemble of four regression models. The learning samples consist of feature vectors, where features are source code metrics computed for a class. The samples are labeled by the Coverageability values computed for their corresponding classes. We offer a mathematical model to evaluate test effectiveness in terms of size and coverage of the test suite generated automatically for each class. We extend the size of the feature space by introducing a new approach to defining sub-metrics in terms of existing source code metrics. Using feature importance analysis on the learned prediction models, we sort source code metrics in the order of their impact on the test effectiveness. As a result of which, we found the class strict cyclomatic complexity as the most influential source code metric. Our experiments with the prediction models on a large corpus of Java projects containing about 23,000 classes demonstrate the Mean Absolute Error (MAE) of 0.032, Mean Squared Error (MSE) of 0.004, and an R2-score of 0.855. Compared with the state-of-the-art coverage prediction models, our models improve MAE, MSE, and an R2-score by 5.78%, 2.84%, and 20.71%, respectively.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑